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 yet
  • translatedString has been translated
  • needs_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 form
  • one - Singular form
  • two - Dual form
  • few - Paucal form
  • many - Many form
  • other - 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

SpecifierDescription
%@Object (String, etc.)
%d, %iInteger
%lldLong integer
%fFloating 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"