Skip to content

Localization

During application development, language switching is an essential feature. The AUBO Scope software currently supports switching between Chinese and English, and plugins developed for it must also switch languages in accordance with the AUBO Scope software's system language.

During plugin development, TS files are first generated using Qt Creator. TS files are the files that implement the translation functionality. There will be as many TS files as there are languages that the AUBO Scope software system can switch between. After generating the TS files, use the Qt Linguist tool to translate all TS files. Finally, repackage the plugin and load it into the AUBO Scope software to enable the plugin to switch languages along with the AUBO Scope software's system language.

Switching Languages in AUBO Scope Software

  1. Launch the AUBO Scope software and click the [Settings] button in the upper-right corner of the home page.

  2. In the [Settings] interface, click "Preferences > Basic Settings", select either [Chinese] or [English], then click [Apply and Restart] in the lower right corner. The language switch in AUBO Scope software will be completed after restart.

Generation, Loading, and Updating of Translation Files

Generating Translation Files

  1. Open Qt Creator, load the plugin project, and arrange the controls in the interface.

  2. Create a new "translations" folder under the plugin's src directory.

  3. Determine the naming convention for translation files.

    1. (Recommended) Use "plugin_name_zh_CN.ts" for Chinese translation files and "plugin_name_en.ts" for English translation files.

      For example: myplugin_zh_CN.ts、myplugin_en.ts

  4. odify the CMakeLists.txt file to include translation files in CMake.

    1. Add LinguistTools translation tool in find_package.

    2. Set the translation file path TS_FILES and create the translation .ts files.

    3. Add .ts translation files in add_library.

    4. Specific code:

      find_package(Qt5 REQUIRED COMPONENTS Core Widgets LinguistTools)
      set(TS_FILES
          ${CMAKE_CURRENT_SOURCE_DIR}/src/translations/loadqrc_zh_CN.ts
          ${CMAKE_CURRENT_SOURCE_DIR}/src/translations/loadqrc_en.ts)
      
      set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${PLUGIN_OUTPUT_PATH}/loadqrc)
      qt5_create_translation(QM_FILES
          ${CMAKE_CURRENT_SOURCE_DIR}/src
          ${TS_FILES})
      add_library(loadqrc SHARED
          ${_srcs}
          ${program_src}
          ${install_src}
          ${QM_FILES}
          src/activator.cpp
          src/resource.qrc)
  5. Save the CMakeLists.txt file, perform CMake and Build again for the project. After completion, the corresponding .ts translation files will be generated in the project/src/translations directory.

Translating Translation Files

  1. Open Qt Linguist and open the .ts file.

  2. As shown in the image, position [1] indicates untranslated phrases; after selecting an untranslated phrase, enter the translation content in position [2]; after entering the translation, click the button at position [3] to mark the phrase as translated.

  3. fter completing all phrase translations, click [Save] in the upper left corner.

Package Plugin

Complete the plugin packaging and compression through the deploy.sh script, copy it to the specified arcs working directory, load the plugin, select Simplified Chinese as the system language to complete the plugin translation loading process. The results are shown below:

Update Translation Files

During plugin development, sometimes after completing the translation functionality for various languages, the plugin may add other features that need translation. In such cases, you only need to update the .ts files.

Below is an example of adding a control "update translation test button" to demonstrate the steps for updating translation files:

  1. Open Qt Creator and add a new control in the plugin project, named "update translation test button".

  2. Locate the .ts files in the project. The storage location of the .ts files in this test case is shown in the image.

  3. Open terminal at the .ts file location and use the lupdate command to update the .ts files.

    1. General format of the lupdate command:

      lupdate -ts translation_file_to_update.ts
    2. If the entire plugin project is managed by CMake, manually add all source code file addresses related to translation content:

      lupdate sourcefile1 sourcefile2 ... -ts ts_file_to_update.ts
    3. If there are many source code files involved, you can use relative paths. Users can adjust according to their project file structure or use absolute paths. In this test project, all source code is stored in the src directory, which is in the parent directory of the .ts files. Use ../* in the .ts file directory to access all files in the src directory:

      lupdate ../* -ts loadqrc_zh_CN.ts
      
      lupdate ../* -ts loadqrc_en.ts
  4. Recompile the project.

  5. Open the .ts file again to check if the newly added control information has been added.

  6. Translate the files, refer to Translating Translation Files for specific operations.

  7. Package the plugin and load it into AUBO Scope to complete the update.

  8. AUBO Scope software can automatically load plugin translation files. During deployment, simply place the qm files in the plugin statistics directory.