[PyQt] Fwd: translation of ui
Yaşar Arabacı
yasar11732 at gmail.com
Fri Jul 1 10:52:09 BST 2011
Hi, me again :)
I got it working but wanted to get an affimation, what do you think of this
approach?
if __name__ == "__main__":
from locale import getlocale
from os.path import exists
app = QtGui.QApplication(sys.argv)
if getlocale()[0]:
if exists("translations/" + getlocale()[0] + ".qm"):
translator = QtCore.QTranslator(app)
translator.load(getlocale()[0] + ".qm", "translations")
app.installTranslator(translator)
window = MainWindow()
window.show()
sys.exit(app.exec_())
01 Temmuz 2011 12:37 tarihinde Yaşar Arabacı <yasar11732 at gmail.com> yazdı:
> That works like a charm thanks :)
>
>
> 01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner <lunaryorn at googlemail.com
> > yazdı:
>
> 2011/7/1 Yaşar Arabacı <yasar11732 at gmail.com>:
>> > Thanks, appearantly I also needed to create a .pro file for pylupdate to
>> > know which files to convert to.
>>
>> Alternatively you can specifiy the files to translate and the
>> translations to update on the command line:
>>
>> pylupdate4 <ui_files> <python_files> -ts <translation_files>
>>
>> > I created a language file and translated it, but how would my
>> application use that translation file?
>>
>> Use "lrelease" from Qt [1] to compile the translations, and deploy the
>> compiled translations along with your program. In your program you
>> need to create a "QTranslator" [2] to load these compiled
>> translations. There a different ways of deploying the translations
>> (e.g. as distutils package data), but the easiest is probably to
>> include them as resource (using "pyrcc4").
>>
>> You should read the "Qt Linguist" manual [3], which describes the Qt
>> translation process in detail, and the corresponding chapter in the
>> PyQt Reference Guide [4], which describes the PyQt specific
>> differences to this process.
>>
>> [1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease
>> [2] http://doc.qt.nokia.com/latest/qtranslator.html#details
>> [3] http://doc.qt.nokia.com/latest/linguist-manual.html
>> [4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110701/a8cab42a/attachment-0001.html>
More information about the PyQt
mailing list