当前位置:网站首页>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: true
And 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
边栏推荐
- Some 5000+ likes, the development notes of a director of cosmic factory, leaked
- Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)
- [template summary] - binary search tree BST - Basics
- Redis single thread and multi thread
- Summary of basic knowledge of exception handling
- Leetcode: a single element in an ordered array
- Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
- How the computer flushes the local DNS cache
- Codeforces Round #768 (Div. 1)(A-C)
- Yyds dry goods inventory Prometheus alarm Art
猜你喜欢
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)
What indicators should be paid attention to in current limit monitoring?
Summary of basic knowledge of exception handling
Programming language (1)
How the computer flushes the local DNS cache
Cesium terrain clipping draw polygon clipping
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Covariance
随机推荐
股票炒股开户注册安全靠谱吗?有没有风险的?
Redis single thread and multi thread
Collection | pytoch common loss function disassembly
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Cognitive fallacy: what is dimensional curse
The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
Oil monkey plug-in
6.0 kernel driver character driver
Cognitive fallacy: Wittgenstein's ruler
Why should enterprises do more application activities?
How can enterprises and developers take advantage of the explosion of cloud native landing?
JS demo calculate how many days are left in this year
webAssembly
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
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
Sed、Awk
Leetcode: a single element in an ordered array
China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet