How to use gettext to make QML files translatable

Solution 1:

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.