Internationalization package.
Extends the BuildContext to easily access the translations
- Update
lib/l10n/*.arb
files with your translations - run
flutter gen-l10n
import 'package:helpwave_localization/localization.dart';
- use
context.localization?.<textId>
orAppLocalization.of(context)?.<textId>
ChangeNotifierProvider(
create: (_) => LanguageModel(),
child: Consumer<LanguageModel>(
builder: (BuildContext context, LanguageModel languageNotifier, _) {
return MaterialApp(
title: "title"
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: getSupportedLocals(),
locale: Locale(languageNotifier.language),
home: Scaffold
)
}
);
If you want to add translations you will have to edit the translations in the l10n folder and for adding a language you will additionally have to add it to the config.