Adding Translations to Perforce QAC
Perforce QAC translations for both the GUI and CLI interfaces can now be added for any language of your choice, using the third party Qt Linguist tool1. These translations will then appear in both the GUI and CLI interfaces.
The following steps describe the process of adding a translation to Perforce QAC, using the German language as an example.
- You need to find the
default.tsin the translations subdirectory of the Perforce QAC installation directory.- On Windows this location would be:
- On Linux, assuming that Perforce QAC was installed in the home folder of user bloggs, this location would be:
C:\Perforce\QAC-<version>\common\translations/home/bloggs/QAC-<version>/common/translations/ - The file
default.tsmust be copied to create a new file, and this new file given a suitable name. Because, in this case, German translations are to be added, it is recommended that the copied file is renamed tode.ts, sincedeis the two-character language code for the German language. A link to a table containing the ISO list of language codes is provided in the links at the end of this section. - The newly created file can then be opened using the Qt Linguist tool. On opening the file, Qt Linguist will prompt you to select the source and target languages. The source language must be left unchanged but you can select your target language. For this example, German must be selected.
- Translations may then be added using Qt Linguist.
- Once the translation file has been updated and saved, the translations can be ’released’ to generate a
.qmfile. This can be achieved by using either Qt Linguist (select File : Release), or theterminal/commandprompt. - For messages containing strings of the type "%1", "%2", and so on, these strings must also be present in the translation. Removal of these strings will cause unexpected behavior in Perforce QAC.
- If a .ts file is modified, the release step must be repeated to generate a new .qm file
- It is not necessary to translate all strings before running the release step. Unfinished translations are simply ignored by Perforce QAC.
- The above procedure can be repeated several times to add translations for multiple languages
- Using the two-character language codes to name the .qm files is recommended since using this convention causes the localized name of the language to be displayed in the Admin : Languages menu. Considering the above example, the additional language would appear as
Deutschand notGerman.
To generate the .qm file in a terminal/command prompt, you need to navigate to the translations subdirectory and run the lrelease command as follows:
On Linux:
cd /home/bloggs/QAC-<version>/common/translations/lrelease de.ts
On Windows:
cd C:\Perforce\QAC-<version>\common\translations\ lrelease.exe de.ts
The file that is generated in our example is called de.qm, which is the file used by Perforce QAC for translation. This new language will appear in the Admin : Languages menu of the GUI and can also be used when setting the language using the CLI.
For example, considering the following source:
Open files %1 and %2
A valid German translation would be:
Dateien %1 und %2 öffnen