当前位置:网站首页>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
边栏推荐
- Awk getting started to proficient series - awk quick start
- Analysis report on the development trend and Prospect of global and Chinese supercontinuum laser source industry Ⓚ 2022 ~ 2027
- How to store null value on the disk of yyds dry inventory?
- Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
- Yyds dry goods inventory Spring Festival "make" your own fireworks
- Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
- Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
- 540. Single element in ordered array
- China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
- js demo 計算本年度還剩下多少天
猜你喜欢
![[automation operation and maintenance novice village] flask-2 certification](/img/9a/a9b45e1f41b9b75695dcb06c212a69.jpg)
[automation operation and maintenance novice village] flask-2 certification

Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)

Introduction to kubernetes
![[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)](/img/b8/e2a59772d009b6ee262fb4807f2cd2.jpg)
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)

IPhone development swift foundation 09 assets

Data consistency between redis and database
![[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)](/img/29/543dce2f24130d22c1824385fbfa8f.jpg)
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)

The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
![[template summary] - binary search tree BST - Basics](/img/78/782129abea06c8e3bef69a121cbce0.jpg)
[template summary] - binary search tree BST - Basics

How can enterprises and developers take advantage of the explosion of cloud native landing?
随机推荐
How to connect a laptop to a projector
[automation operation and maintenance novice village] flask-2 certification
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
[template summary] - binary search tree BST - Basics
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Pooling idea: string constant pool, thread pool, database connection pool
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
How can enterprises and developers take advantage of the explosion of cloud native landing?
6.0 kernel driver character driver
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)
Quick one click batch adding video text watermark and modifying video size simple tutorial
English topic assignment (28)
JS closure knowledge points essence
JS Demo calcule combien de jours il reste de l'année
Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
The difference between SRAM and DRAM
Team collaborative combat penetration tool CS artifact cobalt strike
Overview of Yunxi database executor
Programming language (2)
