String Catalogs and plurals

Accessibility & localization Mid-level Swift 5.9+ iOS 17+ Reviewed By Alok Singh

Pick the fix

You need '1 message' and '5 messages' to be correct in every language. Best approach?

Options
Hint 1 of 1

Who knows each language's plural rules?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Use Text("\(count) messages") and add plural variations for that key in the String Catalog

Correct. Each language supplies its own plural forms.

Why not the others?
  • B count == 1 ? "message" : "messages". English-only logic; many languages have more forms.
  • C Always write 'message(s)'. It reads poorly and doesn't translate.
  • D Build the string from translated words. Word order and grammar differ by language.

30-second answer

A String Catalog (.xcstrings, Xcode 15) is one file holding every localizable string and its translations. Xcode extracts strings from Text("…"), String(localized:) and LocalizedStringResource as you build, and tracks which ones are new, stale or untranslated. For counts, interpolate the number and add plural variations, so each language gets its own forms (Arabic has six, Japanese has one).

Practise saying it · 30 s. No recording, just a timer

Explain String Catalogs.

Say your answer out loud, then check which of these points you covered:

  • One file, auto-extracted
  • Plural variations
  • Translator context

Deep dive

Vary by device too, for example 'Tap' vs 'Click'.

Add comments so translators understand context.

Export and import XLIFF for translation vendors.

Xcode 26 can generate translator comments from source context with its on-device model.

Common mistakes

  • Building plurals with if count == 1.
  • Keys that are never extracted because they're built at runtime.

Senior take & follow-ups

Seniors rely on the catalog's plural rules and give translators context.

Follow-up questions

Think of your answer first, then open the hint.

  1. Why not count == 1 ? "message" : "messages"?

    Show hint

    Many languages have more than two forms.

  2. How do translators get the strings?

    Show hint

    XLIFF export or editing the catalog.

Suggest a fix if something here is wrong or out of date.