Stringsdict File Format

A .stringsdict file is a property list used to define language plural rules.

Avoid using a .stringsdict file with a string that does not include a number, because a language might define generic singular and plural forms in ways that don’t work well with the one and other categories.

Localized String Properties

Each key-value pair in the .stringsdict file defines a plural rule for a specific string, as in:

<plist version="1.0">
    <dict>
        <key>%d file(s) remaining</key>
        <dict>
        </dict>
        <key>%d service hour(s)</key>
        <dict>
        </dict>
        <key>%d award(s)</key>
        <dict>
        </dict>
    </dict>
</plist>

You pass the same strings—for example, @”%d file(s) remaining”, @”%d service hour(s)” and @”%d award(s)”—to a NSLocalizedString macro in your code.

Localized Format String Properties

The plural rule determines the format string returned by the NSLocalizedString macro. You supply a format string for each category of numbers the language defines. The value of this dictionary has the following keys:

NSStringLocalizedFormatKey

A format string that contains variables. A variable is preceded by the %#@ characters and followed by the @ character, as in:

            <key>NSStringLocalizedFormatKey</key>
            <string>%#@files@</string>

where the variable name is files. The format string can contain multiple variables, as in %#@files@ (%#@bytes@, %#@minutes@).

[variable]

A dictionary of key-value pairs specifying the rule to use for [variable], as in:

            <key>files</key>
            <dict>
                <key>NSStringFormatSpecTypeKey</key>
                <string>NSStringPluralRuleType</string>
                <key>NSStringFormatValueTypeKey</key>
                <string>d</string>
                <key>one</key>
                <string>%d file remaining</string>
                <key>other</key>
                <string>%d files remaining</string>
            </dict>

For example, if the number is 2, the @”%d files remaining” format string is returned and the localized string becomes @”2 files remaining”.

Add plural rules for each variable that appears in the NSStringLocalizedFormatKey format string.

Plural Rule Properties

The [variable] dictionary contains the following keys:

NSStringFormatSpecTypeKey

Specifies the type of language rule. The only possible value is NSStringPluralRuleType, which indicates a language plural rule.

NSStringFormatValueTypeKey

A string format specifier for a number, as in %d for an integer. For a list of format specifiers, see String Format Specifiers in String Programming Guide.

zero

The format string to use for the number 0.

one

The format string to use for additional language-dependent categories.

two

The format string to use for additional language-dependent categories.

few, many

Format strings to use for additional language-dependent categories.

other

The format string to use for all numbers not covered by the other categories. This key is required.

For the plural categories and rules for each language, see CLDR Language Plural Rules.