When adding new strings to be localized, update intl_en.arb
, which
is used by this project as the template. When creating new entries, they
have to be in the following format:
"dartGetterVariableName": "english translation of the message",
"@dartGetterVariableName": {
"description": "description that the localizations delegate will use."
},
In this example, dartGetterVariableName
should be the Dart method/property
name that you will be using in your localizations delegate.
After adding the new message in intl_en.arb
, it can be used in the app by
regenerating the GalleryLocalizations delegate.
This allows use of the English message through your localizations delegate in
the application code immediately without having to wait for the translations
to be completed.
Running the application for the first time should generate a synthetic package
containing the app's localizations through importing
package:flutter_gen/gen_l10n/
. The code is generated will be generated in
.dart_tool/flutter_gen/gen_l10n/
.
The generated localizations code is updated every time flutter run
is called, and during hot reload and restart. This means that updates to
existing arb files can be made and seen in real time during app development.
From the root directory, run:
flutter gen-l10n \
--template-arb-file=intl_en.arb \
--output-localization-file=gallery_localizations.dart \
--output-class=GalleryLocalizations
From the root directory, run dart tool/l10n_cli/main.dart
, which
will generate intl_en_US.xml
. This will be used by the internal translation
console to generate messages in the different locales.
Note that the filename for
intl_en_US.xml
is used by the internal translation console and changing the filename may require manually updating already translated messages to point to the new file. Therefore, avoid doing so unless necessary.
See /third_party/dart/flutter_gallery/README.md
for how to import this file and export translations.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。