FLUTTER: Localization of a multi-screen app

♀尐吖头ヾ 提交于 2020-02-29 04:23:36

问题


i'm creating a multi screen app on android using Flutter. I'm using intl to localize it, but i don't understand how to procede to create the arb file. Should i run the following commaand flutter pub pub run intl_translation:extract_to_arb --output-dir=lib\l10n lib\main.dart command for every "page/activity/fragment" of my app?


回答1:


Are you trying to implement in-app localization? i.e. just changing the app's locale without it being affected by the phone's locale? Then you can refer to this blog: https://blog.geekyants.com/flutter-in-app-localization-438289682f0c

The result would look something like this:




回答2:


Start by generating the strings files: 1. Extract all messages to arb file format, which is the template for translations (you can specify multiple files as input.

> flutter pub pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/first_file.dart lib/second_file.dart
  1. Generate translation files in arb format for each language in the form intl_messages_.arb
  2. Generate .dart files for the translations (specify one output for each translation):

    flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n \ --no-use-deferred-loading lib/first_file.dart lib/second_file.dart lib/l10n/intl_messages_en.arb lib/l10n/intl_messages_.arb



来源:https://stackoverflow.com/questions/51630696/flutter-localization-of-a-multi-screen-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!