You can display your project in different languages when you create and link localization
files. The localization files correspond to those of the GNU gettext
system. The format of the localization template files is *.pot (Portable Object Template),
from which localization files *.po
(Portable Object) are generated after translation.
The project can be localized in different languages. However, editing is possible only in the original version.
You configure which categories of text information are localized in the project. Then
you export these texts into a translation template. This template is a file in *.pot
format (example: project_1.pot
). You produce localization files in the format *.po
(example: de.po
, en.po
, or es.po
), either automatically with a corresponding external translation tool or manually
with a neutral text editor. You can import the *.po
files back into CODESYS and use them for localization.
The commands for using project localization are located in the menu “Project Project localization”.
Generating localization templates
Requirement: A project is open.
-
Click “Project Project Localization Create Localization Template”.
The “Create Localization Template” dialog box opens.
-
Activate the categories of text information that should be included in the localization template.
-
“Position information” can also be included in the template. For each text to be translated, specify its location in the project. Select the positions to be displayed in the translation template: only the first position found, all positions found, or none.
-
Click the “Generate” button.
The dialog box opens for saving a
*.pot
file to the file system. Save the localization template. Then you can process the file in a translation tool and generate localization files<language>.po
in the required languages.
Format of the localization template: file *.pot
In the first line, the text categories are specified that were selected for the translation when generating the template:
Example: #: Content:Comments|Identifiers|Names|Strings
: All four categories were selected.
Then each text to be translated is segmented in the form as in the following example:
Example
#: D:\Projects\p1.project\Project_Settings:1 msgid "Project Settings" msgstr ""
Line 1: Position information displayed as source code reference. Displayed only if this has been configured when generating the translation file.
Line 2: Untranslated text as entry msgid
(example: msgid "Project settings"
).
Line 3: Placeholder for the translation: msgstr ""
. Between the single straight quotation marks, the translation in the *.po
file must be inserted in the respective language.
Format of the localization file: *-<language>.po
You can generate a *.po
file with a translation tool or create one using a neutral text editor based on the
*.pot
file. For this purpose, you could change the file extension from *.pot
to *.po
and edit the according to *.po
standard format.
It is imperative to specify the language in the form of the usual culture abbreviation
in the metadata of the file (example: "Language: de"
for German. Then you insert the translations of the individual texts between the
straight quotation marks for the msgstr ""
entries.
Example
"Language: de\n" #: Content:Names #: D:\projects\p1.project\Project_Settings:1 msgid "Project Settings" msgstr "Projekteinstellungen"
Importing localization files / localizing projects
Requirement: For your project, localization files (<language>.po
) were generated based on the translation template *.pot
. The project is open.
-
Click “Project Project Localization Manage Localizations”.
-
Click on the “Add” button.
The “Open Localization File” dialog box appears for selecting a
*.po
file from the file system. -
Select one of the localization files (example:
<project name>-de.po
).The dialog box closes and the affected texts appear in the project in the respective language. For example, if you specify the translation
msgstr "Main program"
for the POU name "PLC_PRG" in the English localization file, then the object name "Main program" appears in the device tree. -
In the same way, you import the localization files for other language targets.
Switching localization, adding and removing localization files
Requirement: All required language are stored in the project by importing the corresponding
*.po
file. The project is open.
-
Click “Project Project Localization Manage Localization”.
The “Manage Localization” dialog box opens. All stored localization files
*-<language>.po
appear in “Files”, as well as the entry “<original version>”. -
Select the desired language and click the “Switch Localization” button.
The project appears in the selected language. When you select “<original version>”, the project is displayed in the original, unlocalized version and it cannot be edited.
Optional: Defining a default localization, toggling localizations
-
Select one of the available localizations and activate the “Default Localization” option.
Click “Project Project Localization Toggle Localization” to toggle the localization between the default localization and original version. By default, this command is also available with the
button on the toolbar.