iOS localization

CEO and founder of Lingohub. Envisioning a multilingual digital world. Email me if you have questions about how Lingohub can help you take your products global.

Helmut Development 0 Comments

SHARE

i18n Resource File Formats: iOS .strings files

Welcome to a new entry in our blog series covering localization (i18n) resource file formats, this time looking at an extremely popular resource file type.

.strings
files are used in the Apple world (e.g. iPhone, iPad, …).

logo170When handling files (for your iOS projects for example), lingohub expects that:

  • key-value pairs are delimited with the equal character (=), and terminated by a semicolon (;).
  • keys and values are surrounded by double quotes (“)
  • place-holders look can be: %.2f, %d, %1$s (regular expression for placeholders: /%[\d|\.]*\$*\d*[dsf]{1}\b+/)
  • comments start at the beginning of the line and span the whole line or multiple lines
  • single-line comments start with double slashes (//)
  • multi-line comments are enclosed in /* */
  • a comment is assigned to the next key-value pair unless there are any blank lines in between
  • on export, single-line comments are exported using single-line syntax, and multi-line comments using multi-line syntax
  • UTF-16LE encoding is expected by default, but users can set different encoding

.strings file example:

// this comment is ignored because it is not directly followed by a key-value pair

/* comments in .strings files 
can be multi line, 
single line */
// or combination of the two
"hello_user" = "Hello %1$s";

// keys and values can be spread to multiple lines
"welcome_message" = "Welcome back, 
we have missed you";

// multi line comments belong to the next key value pair
// as long as they are not interrupted by a white line
"visit_count" = "this is your %1$d visit to our site";

References: