Xcode String Catalogs: what .xcstrings changes for localizing iOS apps
· 7 min read
For more than a decade an iOS app kept its text in two kinds of file: Localizable.strings for plain
sentences and Localizable.stringsdict for plurals, one copy of each per language. Xcode 15 replaced both
with a single file, the String Catalog, saved as Localizable.xcstrings. New projects get one by default,
and Xcode offers to convert the old files.
Inside Xcode the change is pleasant: a table of every string, every language and how far each one has got. Outside Xcode, where translators and localization tools work, it changes more than it looks. This article explains what the file contains and what to keep in mind when it leaves Xcode.
One file for every language
The old layout had a folder per language (en.lproj, de.lproj, …), each with its own copy of
the files. A String Catalog holds all languages at once. It is JSON, and its outline is short:
{
"sourceLanguage" : "en",
"strings" : {
"settings.title" : {
"comment" : "Title of the settings screen",
"localizations" : {
"de" : { "stringUnit" : { "state" : "translated", "value" : "Einstellungen" } },
"en" : { "stringUnit" : { "state" : "translated", "value" : "Settings" } }
}
}
},
"version" : "1.0"
}
Each key has an optional comment for translators and one localization per language. A plain string is a
stringUnit: the text and its state.
The catalog is a source file only. When the app is built, Xcode compiles it into the same .strings and
.stringsdict resources as before, which is why catalogs work with apps that still support older versions
of iOS.
Xcode fills it in for you
The biggest change is not the file format but who writes it. Every time it builds, Xcode looks for localizable text in
your code (Text("Settings") in SwiftUI, String(localized:),
NSLocalizedString) and adds what it finds to the catalog. Nobody has to keep a list of keys by hand.
Two consequences follow.
-
The key is often the English text.
Text("Settings")produces a key calledSettings, and Xcode does not store a separate English value as long as it matches the key. A tool that reads the catalog has to know that a missing source language means "the key is the text". - Strings removed from the code stay in the file. Xcode marks them stale rather than deleting them, so that a translation is not lost because a line of code moved. Old entries pile up until someone removes them.
Translation states
Every localization carries a state. The ones you meet in practice are translated,
needs_review and new. When the source text of a string changes, Xcode flags its translations
for review: the translation is still there, but it may no longer match what the English says. Xcode shows these as
work to do.
This is the same idea most translation tools call "fuzzy", and it is worth keeping when strings travel between tools. If an import throws the state away, nobody looks at those translations again.
Plurals live inside the string
In the old layout a plural lived in a separate .stringsdict file, with a nested dictionary format that
few people wrote by hand willingly. In a catalog, a plural is a variation of the string itself:
"files.count" : {
"localizations" : {
"en" : {
"variations" : {
"plural" : {
"one" : { "stringUnit" : { "state" : "translated", "value" : "%lld file" } },
"other" : { "stringUnit" : { "state" : "translated", "value" : "%lld files" } }
}
}
}
}
}
Each language lists the plural categories it needs: one and other in English, four in
Polish, one in Japanese. (Our article on plural forms explains
why.)
When a sentence contains a number and other values too, Xcode keeps the sentence and the plural apart. The sentence refers to the plural by name, and the plural is defined as a substitution:
"value" : "%#@files@ in %@",
"substitutions" : {
"files" : {
"argNum" : 1,
"formatSpecifier" : "lld",
"variations" : {
"plural" : {
"one" : { "stringUnit" : { "state" : "translated", "value" : "%arg file" } },
"other" : { "stringUnit" : { "state" : "translated", "value" : "%arg files" } }
}
}
}
}
%#@files@ is replaced by the right form of files, and %arg inside that form by
the number. It is powerful, since one sentence can hold two plurals, and it is the part of the format translators
find hardest to read.
Device variations
A string can also vary by device: a shorter text on iPhone, a different one on Mac, "Tap" on a phone and "Click" on a
computer. These are stored as device variations next to the plural ones. They are useful, but they are
specific to Apple platforms, and most tools outside Xcode have no equivalent.
Working with translators outside Xcode
Few translators use Xcode. There are two usual routes for getting text to them and back.
-
Export localizations from Xcode. Product › Export Localizations writes an
.xclocpackage per language, with the text in XLIFF. It is the official route, and also the one with the most steps: export, send, wait, import, for every language and every round of changes. - Send the catalog itself to a localization tool. The tool reads every language from the one file, translators work in its editor, and the developer replaces the file in the project with the updated one. One file in, one file out.
The second route only works if the tool treats the catalog carefully. Things to check:
- keys whose source text is the key itself are recognised, not imported as empty;
needs_reviewsurvives the round trip in both directions;- plural variations and substitutions come back in the same structure Xcode wrote;
- the file is written the way Xcode writes it (keys sorted, the same spacing), so the diff in version control shows only the strings that changed;
- anything the tool cannot represent, such as device variations, is reported rather than silently dropped.
One catalog in a repository is a merge risk
Putting every language into one file has a cost. Two branches that both add strings now touch the same file, and because Xcode rewrites it on every build, the changes can be spread across it. Practical habits help: let only one place, either the developer or the localization tool, write translations at a time, import translations on the main branch rather than on feature branches, and keep the catalog formatted the way Xcode formats it so the merge tool has a chance.
How Stringalize handles String Catalogs
Stringalize imports a .xcstrings file with all its languages in one step: plain strings, plural
variations, substitutions that hold a single plural, and comments, which become notes for translators. Strings in the
needs_review state arrive flagged as fuzzy, and keys that are their own source text are recognised.
Exporting writes a single catalog with every language, in Xcode's own layout, ready to replace the one in your
project. Fuzzy translations go back as needs_review, so Xcode shows them too. Because Stringalize keeps
placeholders in a neutral form, the same strings can also be exported for Android, Flutter or the web.
Two things are not supported yet: device variations, and strings with more than one plural substitution. The import skips them and says how many it skipped, so nothing disappears unnoticed.