Manage the translations

Premise

Typically, a single LocalizationDictionary is sufficient in a project, in which to define all the translations for the strings. Others like them can still be created, for example a LocalizationDictionary for strings displayed in the labels, another for strings displayed in the switches, etc.

Note

if a project is created in Q Studio with the standard template, the Translations folder already contains a LocalizationDictionary.

Create a LocalizationDictionary

In the Project panel, right-click the Translations folder, then click New > LocalizationDictionary.

Set the locales in a LocalizationDictionary

  1. Double click the desired LocalizationDictionary: the translation editor opens.

  2. Click Add local, select the desired locale, and confirm: a new column appears.

  3. Repeat the previous step for each desired locale.

Translate a string

Given a string to translate in a property or in an attribute, proceed as follows:

  1. Double click the desired LocalizationDictionary: the translation editor opens.

  2. Click Display translation References.

  3. In the row of the string to translate, select Synchronize: a key with the same name as the string is created and automatically inserted in the translation table.

    Hint

    to select multiple strings/rows, use the CTRL and MAIUSC keys.

  4. (Optional) Rename the key in the Translation references page.

    Note

    this operation adds a new key in the translation table but does not remove the key with the previous name.

  5. Click Display Translation Table.

  6. Insert the desired translations for the key.

    Note

    if no translation is expected for a locale, the string displayed at runtime depends on the user’s fallback locale.

Use translated texts in a String formatter

In the Format property of a String formatter (see String formatter), reference can be made to a translation key to use the related translated text, according to the session locale at runtime.

  1. To reference the key, in the value field of the Format property type some characters present in the key: the keys containing the typed characters appear.

  2. Select the desired key and press ENTER.

Note

if the text for the key contains placeholders for the String formatter sources (e.g. “{0}”), the relative properties appear.

Import a CSV file with translated strings

It is possible to automatically fill in the translation table of a LocalizationDictionary using by importing strings from a CSV file. The file must meet the following specifications:

  • each key and the associated translations must be in a new row

  • in each row, indicate in sequence the key and the associated translations in double quotes and separated by a comma (e.g.: "Key1", "Traduzione", "Translation")

    Note

    a different separator can be used (see the following procedure).

  • the first row is the header (e.g.: "Key", "it-IT", "en-US")

To import the strings, a predefined NetLogic is available in the template library. To use it, proceed as follows:

  1. In the main toolbar, click image1: the template library opens.

  2. From Scripts, drag the NetLogic Translations importer and exporter into the desired project node (for example inside the Translations folder).

  3. In the NetLogic properties, choose the source CSV file and indicate the separator used.

  4. To import the strings, right-click NetLogic and execute the ImportTranslations* method.

Export a CSV file of translated strings

To export the strings present in all the project LocalizationDictionaries, a predefined NetLogic is available in the template library. To use it, proceed as follows:

  1. In the main toolbar, click image2: the template library opens.

  2. From the Scripts category, drag the NetLogic Translations importer and exporter to the desired project node (for example inside the Translations folder).

  3. In the NetLogic properties, choose an existing CSV file into which the exported strings are to be inserted and the separator to use.

  4. To export the strings, right-click NetLogic and execute the ExportTranslations* method.

See also

Related concepts

Sessions and locale

Related APIs

API for translations

Application examples

Import translations from another project

References

Translation editor