Skip to content

Translation with context using QtLinguist (preferred method)

Onetchou edited this page Jul 23, 2024 · 5 revisions

Return Home

Translations - Using QtLinguist

Pros and Cons of using QtLinguist

Pros:

  1. It provides a user-friendly interface
  2. If configured properly, it displays the context of the translation
  3. It automatically verifies the translations to make sure they respect some important rules

Cons:

  1. The QtLinguist software must be installed
  2. The updated source code of Seamly must be downloaded so that context can be displayed in QtLinguist

What you will need

  1. Qt 5.15.2 (includes Qt, QtCreator, QtChooser, and Qt Maintenance Tool) and Git or Github Desktop for Windows and MacOS. The installation guidelines can be found in the Developer README.

Note : it is possible to translate Seamly2D only downloading QtLinguist, but the process will not be covered by this tutorial. QtLinguist is part of the Qt Tools module. Download Qt from here: (https://www.qt.io/download-qt-installer-oss). During install confirm that the QtTools module is checked.

  1. The source code of Seamly. For this you need to clone the Seamly2D Github repository on your computer. See this tutorial for more explanations : Cloning a repository

Translating Seamly2D with context using QtLinguist, Step-by-Step:

  1. Open QtCreator, then click on "Open a project" and open the Seamly2D.pro project file at the root of the repository you cloned before.

  2. Click on Tools > External > Configure...

  1. In "Linguist > Update translations (lupdate)" change the "Arguments" to -locations relative -recursive -noobsolete "%{CurrentDocument:Project:Path}/share/translations/translations.pro":

then click OK.

  1. Click "Tools > External > Linguist > Update translations (lupdate)". After a few seconds you should have this message in the console at the bottom of the sceeen (in the "General Messages" tab):

image

Doing so, you added to the translation files the necessary information so that QtLinguist could display you the context of the translations.

  1. Now open QtLinguist (linguist.exe) by searching Linguist on your computer. On windows it can be found in "C:\Qt\5.15.2\mingw81_64\bin".

  2. Click "File > Open" and select the translation file you want to modify. The translation files can be found in the \share\translations folder of the cloned repository. To do a full translation of the software in a particular language, you need to finish the translations in those 3 files:

    • measurements_xx_XX.ts
    • qtbase_xx_XX.ts
    • seamly2d_xx_XX.ts

where xx corresponds to the corresponding language.

  1. Please make sure all the validity checks are activated at the top of the screen. They will warn you at the bottom left of the screen if the translation is incorrect. image

  2. Before doing any translation, please read the General translation guidelines

  3. The strings that need to be translated are grouped, depending on where they can be found in the software, on the left of the screen. When the translation is not finished, they are marked with a "?". Click on one of them.

image

  1. You then have the strings to translate at the center of the screen. Click on a string to translate, then enter its translation in the corresponding field. Please look at the context box at the top left of the screen to understand where this particular string will be displayed in the software. Sometimes it will show you a dialog, but sometimes it will only show you the part of the code that displays this particular string.

image

  1. Check at the bottom right of the screen that there is no validity check issue. If so make the corresponding modifications to your translation.

image

  1. If you are sure about your translation, you can validate it using the corresponding ✓ button at the top of the screen (or using the corresponding keyboard shortcut): image

If you are not sure about your translation being correct, just leave it unfinished: image

  1. When you are finished, save the file you're modifying "file > save" and close QtLinguist.

  2. Open QtCreator, then click on "Open a project" and open the Seamly2D.pro project file at the root of the repository you cloned before.

  3. Click on Tools > External > Configure...

  1. In "Linguist > Update translations (lupdate)" change the "Arguments" to -locations none -recursive -noobsolete "%{CurrentDocument:Project:Path}/share/translations/translations.pro":

then click OK.

  1. Click "Tools > External > Linguist > Update translations (lupdate)". After a few seconds you should have this message in the console at the bottom of the sceeen (in the "General Messages" tab):

image

Doing so, you removed from the translation files the context information. This information must be removed to avoid conflicts when implementing the new translations in the software.

  1. Send the modified .ts file to a moderator on the forum 😊