Menu

Translating strings

Help
2016-10-13
2016-10-14
  • Teo Mrnjavac

    Teo Mrnjavac - 2016-10-13

    Hi everyone. I'm porting a Python plugin system for a Qt application from Boost.Python to PythonQt and so far I've been very happy with PythonQt, but I could use some advice on something that doesn't seem to be documented: translations.
    What's the best way to allow embedded Python code to display translated strings from Python string literals? Should I use Python's gettext module with the _ alias, and then set the gettext wrapped string to things like QLabels, etc.? Or would it be better to use QObject.tr provided by PythonQt and have the catalog generator look for Qt's tr in Python code?

     
  • Florian Link

    Florian Link - 2016-10-14

    This is really up to you... You can use QObject.tr and load the translations on startup, or you can go the Python way... both works well, maybe the Qt tools are a bit better. What PythonQt does not have is a tool to find the tr statements and generate a translation file. But it is straight forward to find all the tr statements and generate a cpp file from it.

     

Log in to post a comment.