flutter - 使用动态值与 arb 文件值匹配的 Flutter 国际化
问题描述
我想从本地保存的 .arb 文件中获取翻译。我在循环中有以下代码。因此,如果动态值与 .arb 文件中的值匹配,我就会得到翻译。
Text(Translation.of(context).!filterTitle ),
不幸的是,我找不到如何做到这一点。任何帮助表示赞赏。谢谢
解决方案
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 匹配的动态值。
推荐阅读
- c - 如何为 C 常量结构设置 ANTLR 语法?
- swift - 在 UICollectionView 中的小单元格上使用左插图进行分页
- javascript - 如何更改 React Google Charts 背景颜色?
- android - 在 android studio 中为 FCM 实现 firebase 依赖项时出错
- kotlin - Kotlin 枚举构造函数参数“必须初始化”,伴随对象常量没有限定符名称
- python - 如何将列表转换为字典?
- java - 在不同线程中启动的 ServerSocket 使 JavaFX 应用程序冻结
- prolog - 递归地在序言中创建一个列表
- r - 从现有数据框重塑 R 数据框
- serialization - 为什么在使用手动实现的 Serialize 对具有结构变体的枚举进行序列化到 TOML 时会出现 UnsupportedType 错误?