Apple iOS strings format specification in Respresso

Apple iOS strings files use a fairly simple key-value based approach to store localizations.

Basically, the syntax is: "key" = "value";

You can put a single key-value pair per line.
You can also add line comments with // or block comments using /* Your comment */.

Special characters can be escaped using a \ character. E.g. to a new line character, you need to use the \n string. It works similarly for the backslash and doublequote characters: \\ and \". Fortunately, Respresso handles these automatically, so you don't have to think about them.

Please note that Respresso currently does not support UTF character codes, like \Uxxxx but UTF-8 characters - like emojis - will work just fine.

To separate localizations by language, these files are placed in a folder structure that includes the language identifier.

How Respresso imports it?

Currently, Respresso can import a single .strings file at a time. This is why you have to import it to a preselected language.

Make sure that you import only UTF-8 encoded files. (UTF-16 encoded files might also be imported, but it's not recommended.)

Respresso will import a localization for each line that matches the syntax:

  • The key will become the localization key. (It is treated as an id, so it is used to track updates. See import merging strategy.)
  • The value will become the localization value.
  • If you selected to import variables, Respresso will parse any printf based variables from the imported localization value and register them with a generated name, similar to var_1.

How Respresso generates it?

Respresso will generate a single folder for each localization language you add.

Let's assume that you have 3 languages registered in Respresso:

By default, Respresso will generate the following files:

  • RespressoStrings.bundle/en.lproj/respresso.strings (Containing the en localizations)
  • RespressoStrings.bundle/fr.lproj/respresso.strings (Containing the fr localizations)
  • RespressoStrings.bundle/en-GB.lproj/respresso.strings (Containing the en-GB localizations)

The generated files will contain the following:

  • A single key-value line for each localization key.
  • The key will contain the transformed localization key. (Removing special characters ensures key validity.)
  • The value will contain the localization value. (Special characters will be escaped automatically.)
  • The localization value will contain transformed localization variable placeholder for each registered variable it contains. (In case it contains multiple variables without attribute indexes the computed argument indexes are automatically included.)
  • If there are registered variables a comment will be placed before the key-value line containing the original name and formatting of the variables.

Let's assume you have a single localization with two registered variables in Respresso:
mainScreen.accountBalance: Current balance: {{ balance }} ({{ currency }})

It will output a file like this one:

/*VARIABLES: balance | %'3.2f; currency | %s*/
"mainScreen.accountBalance" = "Current balance: %1$'3.2f (%2$@)";

Notice: The original %s variable format is transformed to the iOS (objective-c) specific variant with forced argument indexing: %2$@