当前位置:网站首页>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
边栏推荐
- Leetcode problem solving - 235 Nearest common ancestor of binary search tree
- On my first day at work, this API timeout optimization put me down!
- [actual combat record] record the whole process of the server being attacked (redis vulnerability)
- China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
- Opengauss database log management guide
- webAssembly
- Data consistency between redis and database
- [flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
- pycuda._ driver. LogicError: explicit_ context_ dependent failed: invalid device context - no currently
- Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
猜你喜欢

2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
![[SRS] build a specified version of SRS](/img/01/0d2d762e01b304220b8924d20277e3.jpg)
[SRS] build a specified version of SRS
![[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list](/img/db/b992d2b461ca17652518a1511b4947.gif)
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list

Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)

string

Opengauss database log management guide

Correlation
![[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)](/img/6e/3ffa91154a718b6ace6c8ca87c5995.jpg)
[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)

How the computer flushes the local DNS cache
随机推荐
Overview of Yunxi database executor
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Correlation
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
IPhone development swift foundation 09 assets
Asynchronous artifact: implementation principle and usage scenario of completable future
Programming language (1)
Mindmanager2022 serial number key decompression installer tutorial
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Harbor integrated LDAP authentication
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)
How can enterprises and developers take advantage of the explosion of cloud native landing?
油猴插件
regular expression
1068. Consolidation of ring stones (ring, interval DP)
[template summary] - binary search tree BST - Basics
The reason why the computer runs slowly and how to solve it
Tkinter Huarong Road 4x4 tutorial III
Preliminary analysis of smart microwave radar module
股票炒股开户注册安全靠谱吗?有没有风险的?
