当前位置:网站首页>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 540. A single element in an ordered array
- How to store null value on the disk of yyds dry inventory?
- Yyds dry goods inventory hands-on teach you to create a jigsaw puzzle using the canvasapi
- Some 5000+ likes, the development notes of a director of cosmic factory, leaked
- Mindmanager2022 serial number key decompression installer tutorial
- [secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
- China's coal industry investment strategic planning future production and marketing demand forecast report Ⓘ 2022 ~ 2028
- Why should enterprises do more application activities?
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
- [flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
猜你喜欢

JS closure knowledge points essence

2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers

Correlation

Opengauss database log management guide
![[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]

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

What indicators should be paid attention to in current limit monitoring?

1068. Consolidation of ring stones (ring, interval DP)

How to solve the problem of requiring a password when accessing your network neighborhood on your computer

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
随机推荐
IPhone development swift foundation 08 encryption and security
Programming language (2)
regular expression
Covariance
string
Buuctf, web:[geek challenge 2019] buyflag
Programming language (1)
Cognitive fallacy: Wittgenstein's ruler
Introduction to kubernetes
Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
BUUCTF,Misc:LSB
Conditional statements of shell programming
[automation operation and maintenance novice village] flask-2 certification
Take you to master the formatter of visual studio code
国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
