gpt4 book ai didi

iOS .stringsdict 不工作

转载 作者:行者123 更新时间:2023-11-28 08:02:57 31 4
gpt4 key购买 nike

我正在尝试使用 iOS 编程中的 .stringsdict 功能来显示数字的正确序数后缀(st、nd、rd 等...)。我已经为英语创建了 .stringsdict 文件,但它只使用“一个”和“其他”键。它忽略了“两个”和“几个”选项。有人看到我在这里做错了什么吗?

文件看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TEAM_RANK_ORDINAL</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@ordinal_string@</string>
<key>ordinal_string</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lu</string>
<key>one</key>
<string>%lust</string>
<key>two</key>
<string>%lund</string>
<key>few</key>
<string>%lurd</string>
<key>other</key>
<string>%luth</string>
</dict>
</dict>
</dict>
</plist>

然后我从 Swift 中像这样访问它。对于值 1,它附加 st,但每隔一个数字附加 th:

    let fmt = NSLocalizedString("TEAM_RANK_ORDINAL", comment: "")
for i in 0...30 {
println(String(format: fmt, i))
}

最佳答案

英语语言环境忽略“两个”和“几个”规则并使用只有“一个”和“其他”。

参见 Plural Rule Properties在“国际化和本地化指南”中:

The meaning of the categories is language-dependent, and not all languages have the same categories.

For example, English only uses the one, and other categories to represent plural forms. Arabic has different plural forms for the zero, one, two, few, many, and other categories. ...

(据我所知)没有办法使用 .stringsdict 文件用于生成序号。

关于iOS .stringsdict 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46095466/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com