Skip to main content

Localizing Projects

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.

Tip

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 (examples: de.po, en.po, 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 ProjectProject Localization menu.

Create localization template

Requirement: A project is open.

  1. Click Project → Project Localization → Create Localization Template.

    The Create Localization Template dialog opens.

  2. Activate the categories of text information that should be included in the localization template.

  3. 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.

  4. Click the Generate button.

    The dialog 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: All 4 categories were selected: #: Content:Comments|Identifiers|Names|Strings

Then each text to be translated is segmented in the form as in the following example:

Example 10. 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 locale code 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 11. 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.

  1. Click Project → Project Localization → Manage Localizations.

  2. Click the Add button.

    The Open localization file dialog appears for selecting a *.po file from the file system.

  3. Select one of the localization files (example: <project name>-de.po).

    The dialog 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" is displayed in the device tree.

  4. 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.

  1. Click Project → Project Localization → Manage Localization.

    The Manage Localization dialog opens. All stored localization files *-<language>.po appear in Files, as well as the entry <original version>.

  2. 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.

Procedure. 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 by means of the _cds_icon_project_loc_toggle_localization.png button on the toolbar.

For more information, see: Command: Toggle Localization and Command: Manage Localizations