Apple stringsdict

Translate supported plural-resource strings while retaining plist control fields and format-selection structure.

Apple plural resources combine the words a reader sees with instructions for selecting the right form. The xcode-stringsdict file handler translates supported string slots in the plist and preserves the control values used by Apple's formatter.

Text slots and control keys #

This fragment defines a count-dependent message:

xml
<plist version="1.0">
<dict>
  <key>items</key>
  <dict>
    <key>NSStringLocalizedFormatKey</key>
    <string>%#@count@</string>
    <key>count</key>
    <dict>
      <key>NSStringFormatSpecTypeKey</key>
      <string>NSStringPluralRuleType</string>
      <key>NSStringFormatValueTypeKey</key>
      <string>d</string>
      <key>one</key><string>%d item</string>
      <key>other</key><string>%d items</string>
    </dict>
  </dict>
</dict>
</plist>

NSStringFormatSpecTypeKey and NSStringFormatValueTypeKey hold control data and are excluded. Other supported <string> values, including NSStringLocalizedFormatKey, become text slots. Keep formatter tokens such as %#@count@ and %d unchanged when reviewing translations.

Slots are matched by their plist key paths within dictionaries and arrays. Empty <string/> elements are also read as string values and can expand to <string>...</string> when a replacement is written.

Reconstruction and plurals #

The current source supplies plist structure. Previous source values identify changes, and matching existing target slots can supply accepted wording. Replacements splice encoded text into the source, retaining surrounding header and formatting for those supported spans.

The handler retains the existing plural-selection structure. It does not synthesize every target-language plural category or prove that its wording works for all quantities. Test the plural resource with the consuming Apple formatter rather than inspecting only one and other in isolation.

Configure and test plural resources #

The CLI infers xcode-stringsdict from .stringsdict; key-scoped mode is unavailable. Select files through CLI configuration or GitHub.

Keep these per-locale resources in the application's .lproj directories alongside string tables. Validate the plist and load it in the app with quantities that select different forms. String Catalogs use a different layout, with several locales inside one shared file.