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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 useQObject.tr
provided by PythonQt and have the catalog generator look for Qt'str
in Python code?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.