v0.9.2 Summary Chapter 8: Plug-ins and UI translations 8. Introduction 8.2. Translating the user interface

8.2. Translating the user interface

Translate pgModeler's user interface requires the use of three tools called lupdate, linguist and lrelease, all them being part of the Qt framework. The lupdate command will scan the pgModeler's source code directory extracting the terms that can be translated and store them in a file called dictionary. The linguist program is the one used to open the dictionaries generated by lupdate and provide the translation of the terms present in that files. Finally, we use the lrelease to generate a compiled version of the translated dictionaries in order to be interpreted by pgModeler at startup. A few steps must be executed in a specific in order to achieve the correct result:

  • Use the most recent pgModeler's source code. You can get it from the download page.

  • Edit the file pgmodeler-intl.pro and add the name of your language file in the form [language]_[TERRITORY].ts. This format is similar to the locale information used by POSIX systems. The .pro file is used by the lupdate command to scan the source code directory and extract the translatable terms. Make sure to add the name of your language file in the variable TRANSLATIONS:

TRANSLATIONS = lang/pt_BR.ts
               lang/zh_CN.ts \
               lang/fr_FR.ts \
               lang/[language]_[TERRYTORY].ts
  • Now we need to generate the dictionaries (.ts files) by running the command below. Once executed you can check the folder lang which will contain the .ts files for each language listed on the TRANSALATIONS variable in pgmodeler-intl.pro: lupdate -no-obsolete pgmodeler-intl.pro

  • Once generated the dictionaries we need to open the desired file in the Qt Linguist application, to do so run the command: linguist lang/[language]_[TERRYTORY].ts

  • After opening the file on Qt Linguist a dialog like the one below will be displayed. Now the hard work begins: you need to translate term by term based upon the Source text field. The translated term must be informed on the [Language] translation field on the middle of the highlight portion on the image below. Finally, you can provide optional comments on the last field. You can get detailed information about Qt Linguist usage on the Qt documentation.

  • Finally, we are able to generate the compiled version of the translated dictionaries. For this task there's the need to run the command lrelease so the output files will be named in the form [language]_[TERRYTORY].qs: lrelease pgmodeler-intl.pro

You can now test the generated dictionary for your native language by normally running pgModeler. If, for any reason, you notice that the translation is not being correctly loaded you must check your system's current language configuration or manually change the language on pgModeler's general settings. Additional guidance and advanced information about the topics described in this chapter can be retrieved directly from the pgModeler's author. It'll be a pleasure to assist anyone who are willing to collaborate with pgModeler.


** Qt Linguist manual **

http://doc.qt.io/qt-5/qtlinguist-index.html

Jan 3, 2020 at 12:33