1、再pubspec.yaml文件中添加:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
运行 pub get packages
2、在 pubspec.yaml 文件中,启用 generate 标志
# The following section is specific to Flutter.
flutter:
generate: true # Add this line
3、在根目录中添加一个新的 yaml 文件,命名为 l10n.yaml,添加一下内容:
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
4、在lib文件夹中,新建文件夹l10n, 添加app_en.arb 和 app_zh.arb模版文件(其他语言文件也是如此)。

app_en.arb文件内容:
{
"@@locale": "en",
"homeTitle": "Home"
}
a

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



