AppLocalizations.of(context)!['dynamic_string']; => 尝试定义运算符“[]”。
但是该类是自动生成的,因此每次构建时都会覆盖该类。 谢谢,如果有人有解决方案。
祝你有美好的一天!
"weekTitle": "Week {weekNumber}",
"@weekTitle": {
"placeholders": {
"weekNumber": {
"type": "int"
}
}
}
然后在你的代码中你可以这样调用它:
AppLocalizations.of(context).weekTitle(_calendarWeek)
您始终可以根据程序中的决定进行分支:
isUsersFirstLogin ? AppLocalizations.of(context)!.Hello
: AppLocalizations.of(context)!.HelloAgain
https://flutter.dev/docs/development/accessibility-and-localization/internationalization#alternative-internationalization-workflows
intl: 0.18.1
flutter_localizations:
sdk: flutter
下面是一个颤振定位的示例
"page_myMovies_listings": "Movies {x} of {y}",
"@page_myMovies_listings": {
"placeholders": {
"x": {
"type": "num"
},
"y": {
"type": "num"
}
}
}
下面是带参数翻译的用法
context.l10n.page_myMovies_listings(10, 100);