English | 简体中文 |
---|
This file covers the translation status of this project, as well as methods to add translations and so on.
Display text in the code is in English. There's a Simplified Chinese translation in the folder i18n
.
The translation file of this project is generated and edited with Qt Linguist. This application is part of Qt, so you could use it by downloading and installing Qt. If you'd not like to download a whole development kit, you can install standalone Qt Linguist from lelegard/qtlinguist-installers.
- Copy the template file
base.ts
,rename it toMusec_xx_XX.ts
, with xx being the language code in ISO 639-1, and XX being the country code ALPHA 2 in ISO 3166.- List of language codes: List of ISO 639-1 codes - Wikipedia
- List of country codes: List of ISO 3166 country codes - Wikipedia
- Open the translation file with Qt Linguist.
- Qt Linguist will detect the language code and country code from the file name automatically. If failed, it will set them by detecting the language and region settings of the operating system. You can select the target language manually. Make sure the target language is correct, then click OK.
- Translate the text.
- If the translation is complete, save the translation file.
If the developer updated the code by changing the display text (e.g. added new display text), then the translation files need an update. lupdate.exe
is a program used to update translation files in Qt. You can check the usage by lupdate.exe --help
.
There are two custom targets in CMakeLists.txt
:
GenerateLocaleBase
, which updatesbase.ts
.GenerateLocaleCN
, which updatesMusec_zh_CN.ts
.
You can add your translation file by duplicating and changing the custom target.
Translation files in the project are listed in the variable TRANSLATIONS
of Musec.pro
. You can set this variable to include your file.
After the file is included, just update them using lupdate.exe
:
<Path to lupdate> <Path to project>/Musec.pro
It's required to release the translation files to target files in order to make use of them in the program. To release a translation file, open the translation file with Qt Linguist, select File -> Release, then a target file is generated in the directory of the translation file. Move the target file to the directory of the program, then the translation can be used by the program.
You can integrate the releasing process in the project file.
Releasing the translation file is a custom command in CMakeList.txt
, and it's executed after building:
# CMakeLists.txt
add_custom_command(TARGET Musec POST_BUILD COMMAND ${Qt5_DIR}/../../../bin/lrelease.exe ${CMAKE_SOURCE_DIR}/i18n/Musec_zh_CN.ts -qm ${CMAKE_CURRENT_BINARY_DIR}\\Musec_zh_CN.qm)
You could change this command in order to release your translation.
Releasing the translation is supported by qmake.
CMakeLists.txt
use the relative path ofQt5_DIR
to findlupdate.exe
andlrelease.exe
. If Qt is installed by the official installer, then the relative path will be okay. Qt could be installed by several package managers (e.g. Conan, vcpkg), in this scenario, make sure you can find these applications on your machine, then editCMakeLists.txt
using the right path (you can use absolute paths).- The extension of the translation file is
.ts
. TypeScript file and transport stream file use this extension as well.