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
Double click the desired LocalizationDictionary: the translation editor opens.
Click Add local, select the desired locale, and confirm: a new column appears.
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:
Double click the desired LocalizationDictionary: the translation editor opens.
Click Display translation References.
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.
(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.
Click Display Translation Table.
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.
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.
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:
In the main toolbar, click : the template library opens.
From Scripts, drag the NetLogic Translations importer and exporter into the desired project node (for example inside the Translations folder).
In the NetLogic properties, choose the source CSV file and indicate the separator used.
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:
In the main toolbar, click : the template library opens.
From the Scripts category, drag the NetLogic Translations importer and exporter to the desired project node (for example inside the Translations folder).
In the NetLogic properties, choose an existing CSV file into which the exported strings are to be inserted and the separator to use.
To export the strings, right-click NetLogic and execute the ExportTranslations* method.
See also
Related concepts
Related APIs
Application examples
Import translations from another project
References