Handle Complex Pluralization with Xcode .stringsdict Files
Master pluralization and variable substitutions in your iOS, macOS, watchOS, and visionOS apps with Lingo.dev's specialized support for Xcode's .stringsdict
format.
Quick Setup
Create an i18n.json
configuration file in your project root:
{
"version": 1.2,
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"xcode-stringsdict": {
"include": ["MyApp/[locale].lproj/Localizable.stringsdict"]
}
}
}
TIP
The [locale]
placeholder in the path will be automatically replaced with each language code (e.g., en.lproj
, es.lproj
).
One Command Translation
Translate all your pluralization rules with a single command:
npx lingo.dev@latest i18n
This automatically:
- Reads your source
.stringsdict
files - Identifies new or modified strings
- Translates only what's changed
- Creates or updates target language files with correct pluralization forms
Understanding .stringsdict Files
The .stringsdict
format is Apple's solution for handling complex pluralization:
<?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>items_count</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>zero</key>
<string>No items</string>
<key>one</key>
<string>One item</string>
<key>other</key>
<string>%d items</string>
</dict>
</dict>
</dict>
</plist>
Lingo.dev intelligently:
- Preserves the XML/plist structure
- Translates only the string content
- Maintains all format specifiers and variables
Smart Pluralization Handling
Language-Specific Rules
Different languages have different pluralization forms:
Language | Plural Forms |
---|---|
English | one, other |
Arabic | zero, one, two, few, many, other |
Russian | one, few, many, other |
Japanese | other (only) |
Lingo.dev automatically generates the correct forms for each target language.
Format Specifier Protection
All format specifiers are preserved exactly as they appear:
%d
,%ld
,%lld
for integers%@
for objects%.2f
for formatted decimals- Named variables like
%#@count@
Advanced Configuration
Multiple Files Support
Include all your project's .stringsdict
files:
"xcode-stringsdict": {
"include": [
"MyApp/[locale].lproj/Localizable.stringsdict",
"MyApp/[locale].lproj/InfoPlist.stringsdict"
]
}
Integration with Other Formats
For complete Xcode localization, combine with other format types:
"buckets": {
"xcode-stringsdict": {
"include": ["MyApp/[locale].lproj/*.stringsdict"]
},
"xcode-strings": {
"include": ["MyApp/[locale].lproj/*.strings"]
}
}
Best Practices
Key Consistency
Ensure your pluralization keys match across formats:
- Use the same key in
.strings
and.stringsdict
files - Reference the same key in your code with
NSLocalizedString()
Testing Pluralization
Test your app with different quantity values to verify all plural forms work correctly across languages.
Why iOS Developers Choose This Approach
- Pluralization Accuracy: Handles complex language rules automatically
- Format Preservation: Maintains exact XML structure required by Xcode
- Incremental Updates: Only translates what's changed, saving time and resources
- Cross-Format Consistency: Works alongside
.strings
and.xcstrings
files - Native Integration: Fits perfectly into Xcode's localization workflow
Related Apple Localization Formats
Lingo.dev supports all Xcode localization formats:
- .strings files: For simple string-by-string localization
- .xcstrings files: Apple's modern all-in-one format
For complex pluralization needs, .stringsdict
remains the most powerful option, especially when working with older Xcode versions or specific pluralization requirements.