当前位置:网站首页>Flutter internationalized Intl
Flutter internationalized Intl
2022-07-03 22:25:00 【nicepainkiller】
Intl It's official , Include for handling internationalization / Localized messages , Date and number format and parsing , Two way text and other international issues .
- pub Address :intl | Dart Package
- Github Address :https://github.com/dart-lang/intl
There was a better one before Android Studio Plug in for :Flutter i18n
- But this plug-in has been out of maintenance for a long time , So it is no longer recommended for everyone
At present, we can use another plug-in :Flutter Intl
- The plug-in is updated and maintained frequently , And widely praised ;
- in addition , stay Android Studio and VSCode Both of them support
Intl Use
step 1:Android Studio Add the plug-in

step 2: Add dependency flutter_localizations
In the project pubspec.yaml In file Used to generate dart file dev_dependencies: flutter_localizations: sdk: flutter

Note that :dev_dependencies:
And then update it !
step 3:Flutter Intl Initialize project ( for the first time )

After success , Automatically in pubspec.yaml At the end of the increase
flutter_intl:
enabled: trueAnd in lib Lower generation generated and l10n
The document states :
- generated Under bag intl Directory default generation messages_all.dart and messages_en.dart file ,messages The first file does not need to be modified manually , It's generated automatically
- generated Under bag I10n.dart yes Localizations and Delegate The implementation of the , No need to modify it manually , It's generated automatically
- l10n There is a intl_en.arb file , This is the English international language content generated by the system by default
step 4: Add language ( chinese -zh)
zh Is the support of Chinese ; Should be default lntl Only joined en Support for

step 5: Add system internationalization support
pubspec.yaml Add package dependency... To the file
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
MaterialApp modify :
MaterialApp( ... localizationsDelegates: [ S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: S.delegate.supportedLocales, ... )edit l10n Under folder .arb file according to json:
{ "app_name": "GBM", "confirm": " confirm ", "cancel": " Cancel " }.arb The file also supports Parameter passing
{ "app_name": "GBM", "confirm": " confirm ", "cancel": " Cancel ", "msg": "GBM:{msg}" }S.of(context).app_name S.of(context).msg(" Hello everyone ")
No, context When using this :S.current.app_name
There is a problem .arb: It doesn't seem to support object ( Cannot nest ); Can only key value:


In this case, there will be more configurations , Then maintain it It's sour !
I don't know Is there a good plan ? For recommendation
边栏推荐
- China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
- 2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
- Buuctf, misc: sniffed traffic
- Plug - in Oil Monkey
- Redis single thread and multi thread
- The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
- The reason why the computer runs slowly and how to solve it
- Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
- Conditional statements of shell programming
- [flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
猜你喜欢
![[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]](/img/55/309c9d52e503405b289bcfc4912be9.jpg)
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]

Go Technology Daily (2022-02-13) - Summary of experience in database storage selection

4 environment construction -standalone ha

IPhone development swift foundation 09 assets

Team collaborative combat penetration tool CS artifact cobalt strike

Cesium terrain clipping draw polygon clipping

2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination

6.0 kernel driver character driver

How to switch between dual graphics cards of notebook computer

Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
随机推荐
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
IDENTITY
Tkinter Huarong Road 4x4 tutorial III
Ten minutes will take you in-depth understanding of multithreading. Multithreading on lock optimization (I)
pivot ROP Emporium
Is it safe and reliable to open an account and register for stock speculation? Is there any risk?
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
1068. Consolidation of ring stones (ring, interval DP)
Cesium terrain clipping draw polygon clipping
Summary of basic knowledge of exception handling
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
油猴插件
Harbor integrated LDAP authentication
Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
Redis single thread and multi thread
国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
Sow of PMP
[automation operation and maintenance novice village] flask-2 certification
6.2 normalization 6.2.5 third normal form (3NF)
