1

我正在为我的 Vapor 解决方案使用 Lingo 包,请参阅: https ://github.com/vapor-community/Lingo-Vapor ,这对于 3 种语言非常适用

现在我需要复数来创建我正在创建的弹出窗口:

for i in stride(from: 1, to: 12, by: 1) {
            if let description = lingo?.localize("lbl_hour_s", locale: language, interpolations: ["count" : i]) {
                option = FormFieldStringOption(key:String(i), label: description)
            } else {
                option = FormFieldStringOption(key:String(i), label: String(i))
            }
            duration.options.append(option)
        }

我的 Json 文件配置如下:

for en_US
"lbl_hour_s" : {"one" : "1 hour", "other" : "%{count} hours"},


for nl_BE
"lbl_hour_s" : {"one" : "%{count} uur", "many" : "%{count} uren", "other" : "%{count} uren"},

(我尝试在 nl 中使用额外的 'many',但在两种情况下仍然得到相同的错误:

缺少语言环境的复数规则:en_US。将默认为other规则。

这有什么问题吗?它看起来与文档中的示例相同:

"unread.messages": {
        "one": "You have one unread message.",
        "other": "You have %{count} unread messages."

还是我需要对 Lingo 进行一些额外的配置?(在文档中没有找到任何东西)

4

2 回答 2

2

问题是 Lingo 没有自动退回到裸语言代码复数规则(例如,从 en_US -> en 当 en_US 不存在时)。

这已在3.1.0版本中修复。

于 2021-03-26T07:47:47.607 回答
1

我发现了我的问题。我使用“en_US”是因为我想在未来提供更多翻译。显然对于美国英语,我应该使用“en”。

比利时的荷兰语(荷兰)口语“nl_BE”也有同样的问题。我想要这个,因为我还添加了“nl_NL”,荷兰的荷兰语口语。两者有 95% 相同,但有些单词或句子不同。

于 2021-03-25T10:33:54.257 回答