Localization No-No: Programmatically Constructing Strings

Given my technical specialization, several of my clients are small-to-medium Russian software companies. Asking me to provide an English translation of their apps/services is often their first step toward software localization. In this post, I want to raise awareness about a common localization no-no: programmatically constructing UI strings.

Don’t construct UI strings programmatically

Why is this a problem? When programmers assemble strings programmatically they do not provide translators with the ability to rearrange elements of a string according to the grammatical and stylistic requirements of the target language. Consider this real-world example.

Source provided to translator: “Будет удалено {messagesCount, plural, one {# письмо} few {# письма} other {# писем}} от”

The client takes this string and programmatically generates a UI string by appending an email address, e.g.

  • If messagesCount = 1: “Будет удалено 1 письмо от dont_try_this_at_home@localization.com”
  • If messagesCount = 2: “Будет удалено 2 письма от dont_try_this_at_home@localization.com”
  • If messagesCount = 5: “Будет удалено 5 писем от dont_try_this_at_home@localization.com”

All of this assumes that the email address properly belongs at the end of the string. This assumption is true for Russian, but it is not true for many other languages, including English. This imposes unnecessary limitations on how translators can translate the string, sometimes preventing a correct translation.

The desired English translation in this case is something like “1 message from dont_try_this_at_home@localization.com will be deleted”, but the client’s code always puts the email address at the end of the string. Don’t do this!

If programmatically generated strings are the wrong way, then what’s the right way?

Do use format strings

The correct way is to provide a format string that includes all elements of the UI string: numbers, email addresses, dates, etc. Translators need the ability to rearrange everything as required by the target language.

Correct source string: “Будет удалено %d письмо от %s”

Correct target string: ” 1 message from dont_try_this_at_home@localization.com will be deleted “

Rely on a tech-savvy linguist

Avoid costly localization errors by writing your code in a localization-friendly way. I can help you bring your app and/or website to a wider audience. Get in touch today for a quote.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s