Skip to main content

Language Pack

Create Language Pack

The client plugin library provides users with the function of loading and displaying interface language packs. Client plugins only support qm file format language packs that can be loaded by QtCreator

In client plugin development, the default language is English. HMI uniformly controls and loads language packs. The following are the loading and using steps:


1. During program development, use the tr() function to construct all string texts that need to be translated.
2. Create a new resource file in QtCtreator
3. In the established resource file, add the folder structure of "/plugin name/language/" hierarchy.
4. Add instructions in the pro file to generate translation files (TRANSLATIONS += language/plugin name_cn.ts).
5. After completing the program, use Qt's update language pack function to generate pre-translation ts files.
6. Use the Linguist software in the Qt development package to open the ts file and perform translation operations. Save after translation is completed
7. After translation is completed, use Qt's generate language pack function to generate translation qm files.
8. Compile to generate user plugins

Create qm File

The following describes the steps and methods to generate qm files

Step 1: In the pro file of the Qt project, add (TRANSLATIONS += language/xplugindemo_cn.ts) to set the path for generating .ts files.

Step 2: In Qt, click "Tools -> External -> Qt Linguist -> Update Translations" to generate ts files

Step 3: Use Qt's language tool Linguist to open the generated ts file.

Step 4: Select the text to be translated, modify it to the target language text in the "Translation" below. After modification, click the "checkmark icon" above. Mark the current text translation as completed. Click save after all translations are completed.

Step 5: Return to Qt and click "Tools -> External -> Qt Linguist -> Generate Translations" to generate qm files