String catalog format
Xcode String Catalogs (.xcstrings) are JSON files that store localizable strings for Apple platforms.
File structure
json
{
"sourceLanguage": "en",
"strings": {
"Hello, World!": {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Hello, World!"
}
},
"de": {
"stringUnit": {
"state": "translated",
"value": "Hallo, Welt!"
}
}
}
}
},
"version": "1.0"
}Translation states
newString has not been translated yettranslatedString has been translatedneeds_reviewTranslation needs review (e.g., source changed)
Pluralization
String Catalogs support CLDR plural categories for handling different grammatical number forms.
Plural categories
zero- For languages with zero formone- Singular formtwo- Dual formfew- Paucal formmany- Many formother- General plural form (required)
Example
json
"%lld items": {
"localizations": {
"en": {
"variations": {
"plural": {
"one": {
"stringUnit": {
"state": "translated",
"value": "%lld item"
}
},
"other": {
"stringUnit": {
"state": "translated",
"value": "%lld items"
}
}
}
}
}
}
}Variables
autoglot preserves all format specifiers and variable substitutions during translation.
Supported format specifiers
| Specifier | Description |
|---|---|
%@ | Object (String, etc.) |
%d, %i | Integer |
%lld | Long integer |
%f | Floating point |
%1$@, %2$@ | Positional arguments |
String interpolation
Swift string interpolation syntax is also preserved:
yaml
"Hello, \(name)!" → "Hallo, \(name)!"
"You have \(count) messages" → "Sie haben \(count) Nachrichten"