All articles
8 min read

iOS Localization with .strings Files: Syntax, Pitfalls and a Workflow That Scales

How Localizable.strings and .lproj folders work, the escaping and format rules that break builds, and why NSLocalizedString comments matter.

iOSMobileLocalization

A build fails on a file nobody touched in months, the error points at line 40-something of a .strings file, and the actual cause is a missing semicolon three entries above the one named in the error. Every iOS developer who's shipped more than one localized app has lost an afternoon to this exact shape of problem, because .strings looks like the simplest possible file format right up until the one time it isn't.

It mostly is simple. A small number of rules account for nearly every real-world failure, and once you know them, .strings stops being a source of surprise and goes back to being what it was designed as: a boring, reliable place to put translated text.

Localizable.strings and the .lproj folder

Apple's localization system organises translated resources by folder, not by filename suffix. Each supported language gets its own directory named <language>.lproj, and inside it sits a Localizable.strings file with the same structure, just different values:

MyApp/
  en.lproj/
    Localizable.strings
    InfoPlist.strings
  de.lproj/
    Localizable.strings
    InfoPlist.strings
  fr.lproj/
    Localizable.strings
    InfoPlist.strings

At runtime, NSLocalizedString (or its modern Swift equivalent) resolves a key against the .lproj folder matching the device's preferred language, falling back through the user's language preference list and finally to the project's development region if nothing matches. There's no separate compile step for you to run, the way gettext has msgfmt – Xcode packages the files into the bundle as part of the normal build, which is also why a malformed one tends to surface as a confusing build error rather than at the line you were editing.

There's a separate Base.lproj folder in most projects too, holding storyboards and XIBs under Xcode's Base Internationalization rather than loose strings – a different mechanism for a different kind of resource, and not where Localizable.strings content belongs even though it sits alongside the language-specific folders in the same project navigator group.

The encoding history worth knowing

.strings files are old-format property lists under the hood, and older tooling defaults reflect that: genstrings, the command-line tool that extracts NSLocalizedString calls into a .strings file, historically wrote UTF-16 by default, and plenty of documentation and sample projects from that era assume it. Modern Xcode reads and writes UTF-8 .strings files without complaint, and UTF-8 is what you want for anything going through ordinary text tools, diff, or version control, where a UTF-16 file with a byte-order mark shows up as a wall of binary-looking noise in a diff. If you inherit a project with old UTF-16 .strings files and start seeing mangled characters after an edit in a plain text editor, that mismatch is usually why – re-saving as UTF-8 resolves it, and there's no reason to go back.

Syntax, and the missing semicolon

The format is deliberately minimal: a sequence of "key" = "value"; pairs, one per line, with C-style comments allowed between them.

/* Shown on the dashboard after a successful sync */
"sync.success" = "All caught up";

/* Button label. Confirms the pending deletion. */
"delete.confirm" = "Delete";

// A shorter, informal variant used in compact layouts
"delete.confirm.short" = "Del";

Every entry needs that trailing semicolon, and this is the detail that causes the most damage for how small it is. Drop one, and Xcode's resource validation doesn't flag just the broken line – the file fails to parse as a whole, which can mean every string in that .lproj silently reverts to showing its raw key, or the build step reports the file as invalid depending on when in the pipeline it gets checked. Either way the symptom (a wall of literal sync.success strings in the UI, or a build that won't archive) looks nothing like "forgot a semicolon," which is exactly why it costs people an afternoon rather than thirty seconds.

Escaping

Inside the quoted value, a literal double quote needs a backslash (\"), a literal backslash needs doubling (\\), and a line break inside a single value is written as \n rather than an actual newline in the file – .strings entries are one logical line each, even when the rendered text wraps across several lines in the UI.

"welcome.message" = "Hi \"Ada\",\nwelcome back.";

Get this backwards – an unescaped quote inside a value, most often from a translator pasting text straight out of a word processor with smart quotes substituted – and you're back to a file that won't parse.

Because a .strings file is an old-style property list underneath, plutil -lint en.lproj/Localizable.strings on the command line will validate it in a fraction of a second, catching a missing semicolon or an unescaped quote long before a full build would tell you the same thing. Worth wiring into a pre-commit hook or a CI step on the file pattern directly – it's cheap enough that there's no reason to wait for a build to surface a one-character typo.

Format specifiers

%@ is the object specifier, used for any NSString-backed value; %d and %ld cover integers at different widths; %f covers floating point. As with every other format in this family, the moment you have more than one argument in a string, position markers stop being optional in any serious sense:

"order.summary" = "%@ ordered %d item(s)";
"order.summary.positional" = "%1$@ ordered %2$d item(s)";

The positional form (%1$@, %2$d) lets a translation reorder the arguments to fit the target language's word order without touching the application code that supplies them – Word order differs enough between languages – German often pushes the verb to the end of a clause, Japanese puts the object before the verb – that a translation regularly needs the arguments in a different order from the English. Leave a multi-argument string in the plain %@ %d form and a translator who needs to reorder the sentence has no way to do it correctly; the only options are a wrong-sounding translation or a translation that silently swaps which value lands where.

Dropped specifiers are the other half of this, and they don't need a build to find. Translatize's placeholder check covers this family – %@, %d and the positional %1$@ alike – and flags a translation that lost one or gained one next to the string in the editor.

NSLocalizedString and the comment that is translator context, not a developer note

let title = NSLocalizedString(
    "checkout.button.submit",
    comment: "Primary button on the checkout screen. Verb, imperative, keep it short."
)

It's tempting to treat the comment argument as a throwaway, especially once you already know what the key means. Don't. That comment is exactly where genstrings writes the /* ... */ block that ends up sitting above the key in the generated .strings file – it's the one piece of context a translator working from the file sees at all, since they're looking at a flat list of quoted strings with no surrounding code. A vague comment, or an empty one, leaves a translator guessing at exactly the kind of ambiguity ("Open" as a verb or as a status label) that a single well-written sentence resolves for free.

String(localized:comment:) is the newer Swift API for the same job, and it takes a comment for exactly the same reason: tell whoever eventually translates the string what it means in context, not just what characters it contains.

InfoPlist.strings for permission prompts

Permission prompt text – NSCameraUsageDescription, NSLocationWhenInUseUsageDescription, and the rest of the Info.plist usage-description keys – doesn't live in Localizable.strings at all. It's localized through a separate file, InfoPlist.strings, in the same .lproj folder, using the identical "key" = "value"; syntax but keyed by the Info.plist key name rather than an arbitrary string identifier you chose yourself:

"NSCameraUsageDescription" = "Nous utilisons l'appareil photo pour scanner vos documents.";

These strings are user-facing and shown by the system, not your app's UI code, the first time a permission is requested – worth treating with the same translation discipline as anything else in the interface, since an English-only permission dialogue in an otherwise fully localized app is a visible, slightly jarring gap.

What this piece is deliberately not covering

Two related mechanisms are worth knowing exist, without pulling them into everything above. Apple handles plurals through a separate mechanism, .stringsdict, which maps a count onto the same CLDR plural categories other platforms use, in its own XML-plist format rather than inline in a .strings file. And recent Xcode versions also offer String Catalogs as a newer, single-file alternative to the .lproj/.strings folder structure, while .strings files remain fully supported for projects that already use them. Both are real parts of the current iOS localization story; neither changes anything written above about how a plain .strings file is structured or where it breaks.

A workflow that scales past the first language

The moment you add a second and third language, hand-maintaining parallel .lproj folders stops being a reasonable way to work – a key added to en.lproj has to be added to every other folder, in the same order, with nothing silently falling behind. The fix is the same one that applies to Android's values-xx/ folders: keep one canonical set of keys somewhere that understands languages as a dimension rather than a folder, and generate each .lproj file from it.

Translatize imports and exports .strings files per language, and because the project holds one shared key set, the same keys that produce your iOS strings also produce the Android strings.xml and the web JSON for the same feature, from the same branch. Exporting a branch's French strings, through the app or directly against the token-authenticated API:

curl -H "Authorization: Bearer $TRANSLATIZE_API_TOKEN" \
  "https://api.translatize.com/v1/integrations/projects/$PROJECT_ID/export?format=ios&lang=fr&branch=feature-onboarding" \
  -o fr.lproj/Localizable.strings

A translated file comes back in exactly the same shape, so importing it through the app completes the round trip. If your canonical source strings live as JSON alongside the iOS project, the CLI covers that half directly – npx @translatize/cli push for new and changed source keys, npx @translatize/cli status --fail-on-missing as the check that fails a pull request before a release ships with an English fallback hiding in a French build. The .strings file itself, like Android's strings.xml, comes out of the app or the API when it's time to hand a locale to a translator or bring a finished one back in, rather than through the CLI's JSON sync.

The NSLocalizedString comment from earlier belongs on the key in Translatize too, as its description. Translators see it next to the string in the editor, and AI translation gets it as context, so the draft has what it needs to tell "Open" the verb from "Open" the status label.

Branching keeps the French strings for an in-progress feature out of what the current build ships with until an admin or owner merges the branch, the same way it does for every other format this project holds – a translator can work a whole feature's worth of .lproj content, submit it for review, and still have no path to touching what's already live until that merge happens.

For the Android side of the same shared catalogue, translating Android strings.xml covers the equivalent folder structure and escaping rules on that platform, and translating Flutter ARB files covers the same problem again for a cross-platform Flutter client sharing the identical key set.

What actually matters here

Get the .lproj folder names right, keep every entry's semicolon, write a real comment on every NSLocalizedString call rather than an empty one, and use positional format specifiers the moment a string has more than one argument. Everything else in .strings is simple enough that it rarely needs a second thought – which is exactly why it's worth getting these few things right rather than finding out which one you skipped from a crash report in a language you don't read.

Keep reading