IOS.stringsdict not working

I am trying to use .stringsdict functionality in iOS programming to display the correct ordinal suffix (st, nd, rd, etc.) for numbers. I created a .stringdict file for English, but only with "one" and "other" keys. It ignores the two and several options. Does anyone see what I did wrong here?

The file looks like this:

<?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>

      

Then I refer to it like this, from Swift. For the value 1, it adds st, but every other number adds th:

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

      

+3


source to share


1 answer


English ignores the "two" and "several" rules and uses only "one" and "other".

See Multiple Rule Properties in the Internationalization and Localization Guide:



The meaning of the categories depends on the language, and not all languages ​​have the same categories.

For example, in English only categories are used one

and other

for are plural forms. Arabic has a different plural forms zero

, one

, two

, few

, many

and other

....

There is (as far as I know) a way to use a .stringdict file to generate sequence numbers.

+3


source







All Articles