Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer

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.

share|improve this answer
Thanks for the answer!. I'm aware of the conversion tools, but they won't make gettext load the translations at runtime. I know it is technically possible by overriding the Qt translate call, as the Unity 2D guys do it in C++, I'm just trying to figure out how to do it in Python. – David Planella May 28 '12 at 9:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.