I'd like to write a QtQuick app based on Python (PySide) and QML.
I know Qt apps have got their own translation technology, but I would like to stick to gettext for this one. I'd like to know if it's possible to:
- Mark strings for translation in QML files in a way gettext tools can extract them into a
.pot
file - Have gettext translate QML files at runtime.
I know this is done in the Unity 2D code, in C++, so I'm wondering how it can be done with Python.
Note: I'm talking about using exclusively gettext at runtime, not about converting between gettext and Qt Linguist formats.
Generally speaking there is no way to use gettext translation in QT because the library uses an internal translation mechanism (Qtranslate and .ts files) as stated here QTBUG-2404.
However, there is a viable alternative.
Shipping with QT there is a toolkit called lconvert that can be used to convert .ts files to .po and vice versa.
So you can extract all of your translation with:
lupdate
Then use lconvert to obtain a po file:
lconvert -of po -o file.po file.ts
After translation you can convert back the po file to ts:
lconvert -of ts -o file.ts file.po
Then you can use it in your software.
lupdate can bu used both for QT an QtQuick.
You can hack the lupdate's source use something you like to substitute qsTr. (is easyly) and then use you hacked lupdate + lconvert + you custome libintl to achieve use gettext objective.