解决使用flutter_intl出现警告No @@locale or _locale field found in intl_en

简介: 解决使用flutter_intl出现警告No @@locale or _locale field found in intl_en

Flutter中使用flutter_intl插件做国际化时,每次修改arb文件后,就会在Message窗口出现以下提示。对于强迫症患者非常难受,必须解决掉!

/Users/ado/Developer/develop_env/flutter_2.10.5/bin/flutter --no-color pub global run intl_utils:generate
INFO: No @@locale or _locale field found in intl_en, assuming 'en' based on the file name.
Process finished with exit code 0

解决方案

ARB介绍

首先我们需要了解arb文件是什么

ARB详细说明:https://github.com/google/app-resource-bundle

ARB全称Application Resource Bundle 是一种基于JSON的本地化格式文件。

根据Google的介绍,@@开头的字段属于Global attributes,必须加在arb文件json格式的最上面。

@@locale用于标记存储在当前arb文件中的字符串属于哪种语言环境。

添加@@locale

通过查看谷歌的说明,我们已经知道了只需要在Json的顶部加上一个字段即可。@@locale或者__locale都可以。推荐使用@@locale,更加符合标准。

值为对应的语言简称。因为我修改的是intl_en.arb文件,所以值为en。

如果是intl_zh.arb,那对应的值就是zh。

{
  "@@locale": "en",
  "appName": "Flutter App",
  ......
}

保存后等插件自动运行,提示就不会出现了。


目录
打赏
0
1
2
0
54
分享
相关文章
Flutter run出现No Provisioning Profile was found for your project‘s Bundle Identifier or your device
Flutter run出现No Provisioning Profile was found for your project‘s Bundle Identifier or your device
177 2
Flutter: Android SDK not found at this location,Android Studio not found at xxx
Flutter: Android SDK not found at this location,Android Studio not found at xxx
326 2
|
11月前
|
API
Flutter 解决Type ‘MouseCursor‘ not found.
Flutter 解决Type ‘MouseCursor‘ not found.
96 0
【错误记录】Flutter 使用 MediaQuery 适配全面屏报错 ( No MediaQuery widget ancestor found. )
【错误记录】Flutter 使用 MediaQuery 适配全面屏报错 ( No MediaQuery widget ancestor found. )
910 0
【错误记录】Flutter 使用 MediaQuery 适配全面屏报错 ( No MediaQuery widget ancestor found. )
【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )
【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )
445 0
【错误记录】Flutter 界面报错 ( No MediaQuery widget ancestor found. | Scaffold widgets require a MediaQuery )
【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )
【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )
288 0
【错误记录】Flutter 构建报错 ( Error: Method not found: ‘CupertinoModalPopupRoute‘. | 下载最新 Flutter SDK 版本 )
【错误记录】Flutter / Android 报错 ( AAPT: error: attribute android:requestLegacyExternalStorage not found )
【错误记录】Flutter / Android 报错 ( AAPT: error: attribute android:requestLegacyExternalStorage not found )
785 0
【错误记录】Flutter / Android 报错 ( AAPT: error: attribute android:requestLegacyExternalStorage not found )
flutter No Material widget found.
flutter No Material widget found.
341 0
【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )
【错误记录】Flutter 组件报错 ( No Directionality widget found. | RichText widgets require a Directionality )
667 0
|
6月前
flutter开发中Use ‘const’ with the constructor to improve performance. Try adding the ‘const’ keyword to the constructor invocation.报错如何解决-优雅草卓伊凡
flutter开发中Use ‘const’ with the constructor to improve performance. Try adding the ‘const’ keyword to the constructor invocation.报错如何解决-优雅草卓伊凡
86 1
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问