This guide explains how to use Lara CLI with Xcode .stringsdict localization files, used for plural rules in iOS and macOS applications.
Xcode .stringsdict files are XML plist files that define pluralization rules for localized strings. They are organized by locale in .lproj directories alongside .strings files and support CLDR plural categories (zero, one, two, few, many, other).
Lara CLI supports .stringsdict files with:
- Single-variable plural entries
- Multi-variable plural entries
- All CLDR plural categories
- Preservation of structural metadata (NSStringLocalizedFormatKey, NSStringFormatSpecTypeKey, NSStringFormatValueTypeKey)
To configure Xcode .stringsdict files in your lara.yaml:
files:
xcode-stringsdict:
include:
- "[locale].lproj/Localizable.stringsdict"
exclude: []
lockedKeys: []
ignoredKeys: []Note: The configuration key is
xcode-stringsdict(notstringsdict). Lara CLI automatically maps.stringsdictfile extensions to this config key.
files:
xcode-stringsdict:
include:
- "[locale].lproj/Localizable.stringsdict"This follows the structure:
MyApp/
en.lproj/
Localizable.stringsdict
fr.lproj/
Localizable.stringsdict
es.lproj/
Localizable.stringsdict
<?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>item_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@items@</string>
<key>items</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><key>transfer_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@files@ in %#@folders@</string>
<key>files</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%d file</string>
<key>other</key>
<string>%d files</string>
</dict>
<key>folders</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%d folder</string>
<key>other</key>
<string>%d folders</string>
</dict>
</dict>zero- Zero itemsone- One item (singular)two- Two itemsfew- Few itemsmany- Many itemsother- Other (default/fallback, required)
Lara CLI flattens plural entries into key paths:
Single-variable entries (one plural variable):
item_count/one->"%d item"item_count/other->"%d items"
Multi-variable entries (multiple plural variables):
transfer_count/files/one->"%d file"transfer_count/files/other->"%d files"transfer_count/folders/one->"%d folder"transfer_count/folders/other->"%d folders"
Lara CLI automatically:
- Extracts plural form values for translation
- Preserves
NSStringLocalizedFormatKeytemplates unchanged - Preserves
NSStringFormatSpecTypeKeyandNSStringFormatValueTypeKeymetadata - Maintains entry ordering from the source file
- Preserves the plist XML structure
files:
xcode-stringsdict:
include:
- "[locale].lproj/Localizable.stringsdict"
lockedKeys:
- "item_count/one" # Lock specific plural form
- "item_count/*" # Lock all forms for item_count
ignoredKeys:
- "debug_count/*" # Ignore all debug plural entriesversion: "1.0.0"
project:
instruction: "iOS app with proper pluralization"
locales:
source: en
target:
- fr
- ar
- ru
files:
xcode-stringsdict:
include:
- "[locale].lproj/Localizable.stringsdict"
lockedKeys: []
ignoredKeys: []- Run
lara-cli initto create your configuration - Ensure your file paths match the
includepatterns - Run
lara-cli translate- Lara CLI will translate all plural form values - Continue developing - changes are tracked via checksums
- Only
NSStringPluralRuleTypeformat specifiers are supported NSStringLocalizedFormatKeytemplates are preserved but not translated (they are structural)- Files must be organized by locale in
.lprojdirectories - Must follow standard Apple plist XML format
- Ensure each variable dict has
NSStringFormatSpecTypeKeyset toNSStringPluralRuleType - Verify the plist XML is well-formed
- Check that plural form keys are valid CLDR categories
- Verify the entry has at least one plural variable dict
- Check that the
NSStringLocalizedFormatKeyreferences the variable correctly
- Supported Formats - Overview of all supported file formats
- Files Configuration - General file configuration options
- Xcode Strings Files - Simple string localization
- Xcode String Catalogs - Modern Xcode 15+ format