2

I am trying to produce the following localized string:

"In ___ day(s)" --> (ex: In 5 days)

To accomplish this, I've gone down the .stringsdict route:

<key>In %d Days</key>
    <dict>
        <key>NSStringLocalizedFormatKey</key>
        <string>%#@Days@</string>
        <key>Days</key>
        <dict>
            <key>NSStringFormatSpecTypeKey</key>
            <string>NSStringPluralRuleType</string>
            <key>NSStringFormatValueTypeKey</key>
            <string>d</string>
            <key>zero</key>
            <string>Today</string>
            <key>one</key>
            <string>In %d Day</string>
            <key>other</key>
            <string>In %d Days</string>
        </dict>
    </dict>

I then use the following, to obtain a localized string:

NSInteger days = ...;
localizedDueDateString = [NSString localizedStringWithFormat:NSLocalizedString(@"In %d Days", @"Indicates days"),ABS(days)];

This correctly outputs a string that accounts for plurality. For example:

In 1 day
In 4 days

I am wondering if the "1" and the "4" here will be localized correct. Other languages, like Arabic for example, have different symbols for their numerals. I would expect the above string to use the symbol "٤" instead of "4", for arabic.

I know this can be accomplished using an NSNumberFormatter, but how can I accomplish numeral localization while ALSO respecting plurality visa vi a .stringsdict file?

4

1 回答 1

2

是的

当使用 .stringsdict 文件与“localizedStringWithFormat”方法协调时,数字似乎确实被正确交换了!

我将 iPad 语言切换为阿拉伯语,输出为

In 1 day

曾是...

١ day In 

我还没有完成阿拉伯语本地化,所以“In”和“day”是英文,但数字似乎已正确本地化。不需要 NSNumberFormatter

于 2016-01-21T02:47:38.340 回答