首页 > 解决方案 > 使用动态值与 arb 文件值匹配的 Flutter 国际化

问题描述

我想从本地保存的 .arb 文件中获取翻译。我在循环中有以下代码。因此,如果动态值与 .arb 文件中的值匹配,我就会得到翻译。

 Text(Translation.of(context).!filterTitle ),

不幸的是,我找不到如何做到这一点。任何帮助表示赞赏。谢谢

标签: flutterlocalizationflutter-localizations

解决方案


2天后,我得到了答案。希望能帮助某人。您需要使用 .arb 文件的选择功能

"facetTitle": "{facetTitle, select, age_group{Age Group} product_type{Product Type} collection{Collection} gender{Gender} other {{facetTitle}}

并在下面的 dart 文件中使用

S.of(context).facetTitle(text1) 

text1 是与 .arb 文件中的 select 匹配的动态值。


推荐阅读