Project Language Translation (Localization)
PLCnext Engineer supports the translation of comments and HMI texts into other languages.Two different methods are currently available:
- The HMI application provides the predefined application local tag LanguageCode with which the language of user-defined text strings (e.g., object labels, etc.) can be switched when executing the HMI application. The HMI application then reads prepared translations from the 'Resources' editor.Refer to the topic "Localization of the HMI Application" for further information.
- The GET_LANG_STRING/GET_LANG_WSTRING function blocks can be integrated in the application code. The FBs can read prepared translations of variable comments, user-defined texts (e.g., message texts) as well as free code comments from the 'Resources' editor of the respective POU and write them into a user-defined string variable. Such a target string variable can then be further processed in the application and/or visualized in the HMI application. See the section "Localization using the GET_LANG_STRING/GET_LANG_WSTRING FBs" below for further information.
Selecting the default language and target languages
Precondition for using the localization feature is that a default language and at least one alternative (target) language are set in the 'Options' dialog:- Select 'Extras > Options'.
- Click the 'International' folder and select the 'Default Language Settings' category.
- Choose a 'Default' language.
- Define the alternative languages (target languages to be switched to): In the 'Available' group, select the respective entry and click 'Add Alternative'. The language is added to the 'Alternative' group (shows the list of available national languages in the project). Repeat this step for the desired languages.(You cannot add own languages to the 'Available' group.)
- Confirm the 'Options' dialog with 'OK'.
- Restart PLCnext Engineer to apply the changes.
Localization using the GET_LANG_STRING/GET_LANG_WSTRING FBs
Prior to performing the following steps, make sure that the project localization feature is activated in the 'Options' dialog and the desired target languages are added as alternative languages. See the description above.
- If variable comments are to be translated: Open the 'Variables' grid of the respective POU.
Activate the 'Translate' flag of the desired variables.Note
The 'Translate' variable property is not available in Data Lists. Instead of specifying the global declaration as translatable, this has to be done at the External declaration in the local variables tables. - Open the 'Resources' editor of each POU where texts are to be translated.
- In the 'Resources' editor, the translatable variable comments (section 'Variables') and free code comments (section 'Code') are already collected from the variables and code worksheets.You can add free user-defined text in the section 'User'.
- Fill in the translations in the target language columns. (The available target language column depend on the settings in the 'Options' dialog.)A mechanism to support external computer-aided translation will be available soon.
- Insert the GET_LANG_STRING or GET_LANG_WSTRING function block into a code worksheet. The FBs are contained in the PLCnext Controller library.Connect the formal parameters of the function block. Refer to the function block description
‣ GET_LANG_STRING
×‣ GET_LANG_WSTRING
× for details.Specify the string in the 'Resource' table as follows: POUname.TableSection.ID The strings applied to the FB inputs LANG_CODE and STRING_NAME can, for example, be provided by an upstream code part using character string functions (such as Concat, Find, etc.).By further processing the resulting string applied to the LOCALIZED_STRING FB output, the localized string can, for example, be visualized in the HMI application or evaluated in the code in order to control the application.