The application localization process uses .ts files as specified by the Qt .ts file format. Instead of source strings that Qt localization is based on, the localization can use unique text ID for each localizable text string.

Creating .ts files

Design all the text strings in the application, as well as the source for them, right in the early stages of the software project. As a developer, you just need to know enough about the format and content of the .ts files to handle the implementation part of the localized .ts files.

To support the translators' work, the .ts file can also provide additional comments (as allowed by the .ts format). Sufficient commenting helps the translator to visualize the context where the text string occurs. It also helps them to decide which words can be omitted or abbreviated, if necessary, without reducing understandability and usability.

To create the different translations from the .ts file, you can use the NTR tool available on Nokia Developer website.

Note: The

.ts files are just the human-readable 'source' format of localization files. The .ts files need to be generated into binary .qm files, from which the application can search and display the translations in the UI.

Make sure all the language-specific .ts files are named correctly.

Using placeholders in text strings

You can use placeholders in text strings to insert content at runtime. For example, when you want to display a question such as Add <person X> to chat contacts? to the user, use a placeholder in the text string to mark the place where the person's name will be inserted. The actual inserting is done in code using arguments.

When you create text strings that use placeholders, remember the following guidelines:

  • Do not use placeholders when referring to numbers of technical standards and version numbers. Use numbers in the text string, for example, 'PIN2 code' and 'Japanese (ISO 2022)'.

  • In some cases, it may be necessary to limit the length of inserted content. For example, the length of text may vary considerably in different languages, and different display sizes pose different limitations on the space available for the string.

  • In general, avoid using too many placeholders in one string:

    • With multiple placeholders, translations can easily become difficult to understand for end users. This is because the length of inserted content is often unpredictable, and it may have to be abbreviated if space is limited. For example, if a string contains both a username and a service name, the translation of the inserted text may have to be severely abbreviated. The resulting text string may no longer be very informative, or even understandable (for example, 'abcd... has logged in Abcd...').

    • If a string has multiple placeholders and little text to provide context, translators may have difficulties understanding the meaning of a particular placeholder.

When numbering the placeholders, always start from 1, and continue in order. You can use a mixture of different placeholder types in one string, as long as the numbering runs correctly (for example, %1, %Ln, %L2).

Defining singular and plural forms in the .ts file

If a language uses plurality, this affects the translations needed for text strings. Depending on the language, the plural form may have nothing to do with the text element in singular form: the stem of the word may be completely different, and the inflection may also vary. For example:

  • Some languages do not use plural forms at all (for example, Chinese and Japanese).

  • Some languages use different forms to indicate duality and plurality (for example, Russian).

  • The form used with zero (0) can be different: some languages use singular and some use plural.

  • Some languages use different forms for specific numbers. For example, Arabic uses various different forms such as a form for zero, singular, dual, "minority plural", plural, and plural for 100, 200, and so on.

This also determines how many translations a specific language requires for a text string. Depending on the language, there can be 1-6 translations. For example:

  • Chinese only requires 1 translation, because the same form of the noun is used with any number.

  • English requires 2 translations: one for '1', and another one for other numbers ('0' also uses the plural form).

  • French requires 2 translations: one for '0' or '1', and another one for other numbers.

  • Polish requires 3 translations: one for '1', another one for '22', '32', '42' and so on, a third translation for other numbers.

Note: One text string can contain only one %Ln placeholder. If the text string contains two placeholders indicating quantity, you need to implement plural support by creating four separate alternatives:

  • %L1 file, %L2 folder

  • %L1 file, %L2 folders

  • %L1 files, %L2 folder

  • %L1 files, %L2 folders

For numbers that do not indicate quantity (for example, Group %L1) and thus do not require multiple translations, use the number placeholder format %L1, %L2, and so on.

Qt provides a numerus.cpp file (available in sf\mw\qt\tools\linguist\shared\), which defines the singular and plural forms used in each of the supported languages.

You define the singular and plural translations needed using numerusform tags in the .ts files. You must define the translations in correct order, matching the order specified in numerus.cpp. For example, you would define English translations in this order:

      <numerusform>%Ln translation</numerusform>
      <numerusform>%Ln translations</numerusform>

You insert the quantity in the placeholder using arguments in code.