Skip to content

2.5 Adding language translations

Josh Morgenstern edited this page Jul 24, 2021 · 2 revisions

For instructions for translators, see language translations documentation

How to add a new translation language to fritzing

First find the official two letter language code, for example in this list of ISO 639-1 codes.

Now go to the fritzing source folder and open .../pri/translations.pri in a text editor. Add a new language at the bottom: assuming your two letter language code is "xy", you would add the following line:

translations/fritzing_xy.ts \

Note that some language codes also need a two-letter dialect extension. If you encounter such a language, take a look at the existing set-up for Chinese or Portuguese dialects.

Next, in order for the translation to show up in the Language drop-down in the Preferences dialog, open up .../src/dialogs/translatorlistmodel.cpp, and add the new language to the m_languages table in the constructor (follow the example of the languages already there). Many language names contain UTF-8 characters. There are instructions for dealing with this in translatorlistmodel.cpp.

How to generate translation files

cd to the fritzing source folder (the one containing "phoenix.pro"), then run lupdate (a tool provided by Qt). For example:

C:\Qt\qt-everywhere-opensource-src-4.8.5\bin\lupdate.exe phoenix.pro

There is also a .bat file under .../tools. Lupdate pulls all of the tr() text out of the source files and updates the set of .ts files in the translations folder.

To generate the binary translation (.qm) files that fritzing actually uses at runtime, cd to the fritzing source folder, then run lrelease (a tool provided by Qt). For example:

C:\Qt\qt-everywhere-opensource-src-4.8.5\bin\lupdate.exe phoenix.pro

Again, there is also a .bat file under .../tools.