symbolStrings.po contains all translatable strings collected from each library part in the library package. This includes:
-
parameter descriptions (which appear on the All Parameters tabpage and in listfields)
-
string parameter values (note that the default string value can be overwritten by mapping values as well (Creating parammapping.xml and MappingDefinitions.json), in that case it has priority over the translation)
-
library part description
-
library part keywords
-
and all script strings that are “marked for translation” (see below).
Note that the translations are not applied while in the GDL Editor.
Marking script strings for translation
GDL uses multiple quotation mark variations for displaying strings, but only one of these variations means that the string will be translated. The format looks like this:
_('string to be translated')
This means that the string provided between _(‘ and ‘)* will appear in the dictionary file, called symbolStrings.po, and it can be given a translated version for selected languages.
*Other quotation marks work, too; the only requirement is the format _(<quotation mark> and <quotation mark>). So the following versions are acceptable as well:
_("string")
_(´string´)
_(`string`)
Ensure you only mark strings that need to be translated (e.g., when displaying numbers or units on the interface, they are not translated).
Also, try not to cut strings into smaller parts, as the order of words may differ between languages.
Generating raw symbolStrings.po
Once you are done with your scripts and marked the necessary strings for translation, convert your code to hsf. After that, run the following LP_XMLConverter command:
Windows:
<path>\LP_XMLConverter.exe hsf2l -symbolstringstodictionary <dictionaryfolder> <source> <destination>
Mac:
<path>\LP_XMLConverter.app hsf2l -symbolstringstodictionary <dictionaryfolder> <source> <destination>
dictionaryfolder: path of folder in which the symbolStrings.po will be created
source: path of the library package hsf folder
destination: path of folder in which the library will be converted to binary (not used for this process, can be a temporary folder)
A symbolStrings.po file looks like this (where the msgstr – the translation – gets the same value as msgid – the original string – during the file generation):
#: <libpartname1>.gsm
#: <libpartname2>.gsm
msgctxt "Parameter Description"
msgid "original string 1"
msgstr "translated string 1"
#: <libpartname1>.gsm
#: <libpartname3>.gsm
msgctxt "Script String"
msgid "original string 2"
msgstr "translated string 2"
#: <libpartname3>.gsm
msgctxt "Library Part Keyword"
msgid "original string 3"
msgstr "translated string 3"
#: <libpartname3>.gsm
msgctxt "Library Part Description"
msgid "original string 3"
msgstr "translated string 3"
#: <libpartname2>.gsm
msgctxt "Parameter Value"
msgid "original string 5"
msgstr "translated string 5"
Translations in symbolStrings.po are grouped in blocks. Each block is translating a single string (which can be found in multiple library parts).
#: – lists all the library parts in the block that contain the string (e.g., libpartname1 and libpartname2 both contain “original string 1” as a parameter description in the example above).
msgctxt – context of the string, which can be Parameter Description, Script String, Library Part Keyword, Library Part Description, or Parameter Value. If the exact string appears in different contexts, you can translate them differently if needed, but in most cases, the translation is the same.
msgid – string to be translated
msgstr – translated version of the string
Translating strings
Create a copy of the previously generated symbolStrings.po with a new name (preferably one that reflects the language version to which the dictionary applies). In the copy, you can enter the translations for each string after msgstr.
Create a separate file for each language version you wish to cover in translation.
Editing .po files
Read more on the .po files and their editing here: GNU gettext utilities
Adding to the library package
Follow the step-by-step process provided in Create a New Libpack From Scratch/Upgrade .lcf to .libpack: save all created symbolStrings.po files, return to the step-by-step article, and add them later in the Packaging the Library section.