script/i18n_builder
dart run.dart .
cd script/i18n_builder #
dart run.dart . # lib I18n
run.dart
cd script/i18n_builder #
dart run.dart -D=lib,src,app -N=S # lib/src/app S
lib/src/app
S
: I18n
S.of(context).XXX
json
languageCode_countryCode.json
`{}`
{=}
---->[]----
I18n.of(context).info2(count: '$_counter')
I18n.of(context).info2(count: '$_counter',user: 'toly')
pubspec.yaml
flutter_localizations
dependencies:
#...
flutter_localizations:
sdk: flutter
MaterialApp
tag1
: I18nDelegate
tag2
:tag3
:MaterialApp(
//...
localizationsDelegates: [ // tag1
...GlobalMaterialLocalizations.delegates,
I18nDelegate.delegate
],
supportedLocales: I18nDelegate.delegate.supportedLocales, // tag2
locale: const Locale('zh', 'CH'), // tag3
);
tag3
locale