A plugin which supports code generation for i18next.
Add the config to the build.yaml
:
targets:
$default:
builders:
i18next_code_gen:
options:
localizations: lib/i18n/en-US/*.json
Replace en-US with the main language. It is also possible to
add an out
-option to change the output file. The default file is
lib/i18n/localizations.i18n.dart
. Another option is to add
flutter: false
to support dart only environments.
Run the code generator once with dart run build_runner build
or
add a listener with dart run build_runner watch
.
Get the localization by importing /i18n/localizations.i18n.dart
and calling Localization.of(context)
. This returns a variable which
contains sub-variables and sub-sub-variables to get the localization.
Supports all Dart and Flutter environments.