iOS .stringsdict无效 [英] iOS .stringsdict not working
问题描述
我正在尝试在iOS编程中使用.stringsdict功能来显示数字的正确序数后缀(st,nd,rd等)。我已经为英语创建了.stringsdict文件,但它只使用了'one'和'other'键。它忽略了两个和少数选项。有谁看到我在这里做错了什么?
I'm trying to use the .stringsdict functionality in iOS programming to display the proper ordinal suffix (st, nd, rd, etc...) for numbers. I've created the .stringsdict file for english, but it's only using the 'one' and 'other' keys. It's ignoring the 'two' and 'few' options. Anybody see what i've done wrong here?
该文件如下所示:
<?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,但每隔一个数字追加:
I then access it like so, from Swift. For the value 1 it appends st, but every other number appends th:
let fmt = NSLocalizedString("TEAM_RANK_ORDINAL", comment: "")
for i in 0...30 {
println(String(format: fmt, i))
}
推荐答案
英语区域设置忽略两个和少数规则并使用
只有一个和其他。
The english locale ignores the "two" and "few" rules and uses only "one" and "other".
参见多个规则属性:
类别的含义取决于语言,并非所有
语言都具有相同的类别。
The meaning of the categories is language-dependent, and not all languages have the same categories.
例如,英语仅使用一个
,其他
类别t o
代表复数形式。阿拉伯语有不同的复数形式
零
,一个
,两个
,少数
,多
,其他
类别。 ...
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文件
来生成序数数字。
There is (as far as I know) no way to use a .stringsdict file for producing ordinal numbers.
这篇关于iOS .stringsdict无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!