Localizing the PLC project

You can display your project in different languages if you create and integrate localization files. The localization files correspond to those of the GNU “gettext” system. The localization template files are *pot files (Portable Object Template) from which localization files are created in *.po format (Portable Object) after the translation.

Localizing the PLC project 1:

Although the project can be presented in different languages, editing is only possible in the original version.

You configure which categories of text information contained in the project you want to localize. Then you export these texts into a translation template. This template is a file of the format pot (for example "project_1.pot"). The template serves as a basis for creating localization files in po format (e.g. "de.po", "en.po", "es.po"), using a suitable external translation tool, or manually using a simple text editor. You can then import the po files back into TwinCAT and use them for the localization. The commands for managing the project localization can be found in the menu PLC > Project Localization.

Generating a localization template

A project is open.
1. Select the command Create Localization Template in the menu PLC > Project Localization.
The Generating a localization template… dialog opens.
2. Select the text information categories you want to include in the localization template.
3. "Position information" can also be included in the template. For each text to be translated you specify its location in the project. Here you can select whether only the first instance of the text that was found, all instances or none should be displayed in the translation template.
4. Click Create.
The dialog for saving a file in pot format opens. Save the localization template. You can then edit the file in a translation tool and create <Language>.po localization files in the desired languages.

Format of the localization template (file *.pot))

The first line shows which text categories were selected for translation when the template was created:

Example:

#: Content:Comments|Identifiers|Names|Strings: All four categories were selected.

For each text to be translated, this is followed by a section in the form shown in the example below:

Example:

#: D:\Projects\p1.project\Project_Settings:1
msgid "Project Settings"
msgstr ""

Line 1: Position information as source code reference: This is only shown if it was configured when the translation file was generated.

Line 2: Untranslated text as entry msgid. Example: msgid "Project Settings".

Line 3: Placeholder for the translation: msgstr "". The translation in the respective language must then be inserted between the quotation marks in the po file.

Format of the localization file (file *-<Language>.po)

You can create a po file using a translation tool or manually using a neutral text editor based on the pot file. You could rename the pot file to a po file and then edit it according to the standard po format. Be sure to specify the language in the metadata of the file in the form of the usual language tag.

Example: "Language: de" for German.

Enter the translations of the individual texts into the msgstr "" entries between the quotation marks.

Example:

"Language: de\n"
#: Content:Names
#: D:\projects\p1.project\Project_Settings:1
msgid "Project Settings"
msgstr "Projekteinstellungen"

Importing the localization files (localizing the project)

Localization files <language>.po were created for your project, based on the *.pot localization template. The project is open.
1. Select the command Manage Localization … in the menu PLC > Project Localization
2. Click Add.
The Open Localization File dialog for selecting a po file from the file system appears.
3. Select one of the localization files, for example “<project name>-de.po”.
4. The dialog closes, and the affected texts appear in the corresponding language in the project. For example, if you have entered the translation msgstr "Hauptprogramm" in the German localization file
for the function block name MAIN , the object name Hauptprogramm appears in the PLC project tree.
5. Import the localization files for the other languages, for which translations exist, in the same way.

Changing the localization (adding and removing localization files)

All the required languages are stored in the project after importing the corresponding po files.
The project is open.
1. Select the command Manage Localization … in the menu Project > Project Localization.
The Manage Localization dialog opens. All stored localization files *-<language>.po and the entry <original version> appear under Files.
2. Select the required language and click Switch Localization.
The project appears in the selected language. If you select <original version> the project appears in the original, non-localized version and can be edited again.

Optional: specifying a standard localization (Toggle Localization)

Select one of the available localization and enable the option Standard Localization.

Use the command Toggle Localization in the menu PLC > Project Localization to switch the localization between the standard localization and the original version. By default, the command is also available via the Localizing the PLC project 2: button in the toolbar.

See also: