Dec*_*oth 5 messageformat dart flutter
更新到 Flutter 3.7.0 后,我在构建应用程序时收到此错误消息:
[app_en.arb:scanCode_fieldNotMatched] ICU 语法错误:预期为“标识符”,但发现为“0”。要匹配的字段是“{0}”
.arb 本地化文件中变量的写入方式似乎发生了变化。
如果您尝试在字符串中使用字符{, }, \'(或任何其他语法字符),那么您将必须转义它们。为此,请use-escaping通过将以下内容添加到l10n.yaml来启用该标志
use-escaping: true\n\nRun Code Online (Sandbox Code Playgroud)\n现在使用成对的单引号来转义语法字符,例如“{”。要转义单引号,您只需将其写为双单引号,如下所示:
\n{\n "some_text": "Using the \'{\' character \'{isn\'\'t}\' trivial?"\n}\nRun Code Online (Sandbox Code Playgroud)\n有关此内容的更多详细信息,请参阅flutter docu。
\n请关注本期的详细信息。
\n我发现这个错误的原因是在Flutter 3.7中
\n\n\n国际化支持已彻底改进![他们]\xe2\x80\x99已经完全重写了gen-l10n工具...
\n
正如发布帖子中所述。
\n以前我在.arb文件中声明字符串如下
\n"scanCode_fieldNotMatched": "field to match is \\"{0}\\"",\nRun Code Online (Sandbox Code Playgroud)\n之后我{0}用其他值替换。
好吧,看来现在该gen-l10n工具将括号之间的内容作为特殊参数,并且该名称"0"不被接受,所以我不得不将字符串更改为
"scanCode_fieldNotMatched": "field to match is \\"{value0}\\"",\nRun Code Online (Sandbox Code Playgroud)\n现在可以AppLocalizations称为:
AppLocalizations.of(context)!.scanCode_fieldNotMatched("something here to replace value0!")\nRun Code Online (Sandbox Code Playgroud)\n有关此内容的更多详细信息,请参阅:Placeholders,plurals, and selects in Flutter。
\n| 归档时间: |
|
| 查看次数: |
1437 次 |
| 最近记录: |