Re: [PyQt] Fwd: translation of ui
2011/7/1 Yaşar Arabacı yasar11...@gmail.com: 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_()) I'd use QLocale.system().name() instead of locale.getlocale(), as recommended in the Qt documentation. The rest looks ok. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
* Yasar Arabaci (Fri, 1 Jul 2011 12:52:09 +0300) 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_()) This is all I have in my (template-like) application: app = QtGui.QApplication(sys.argv) # Internationalization appTranslator = QtCore.QTranslator() appTranslator.load(':/app.qm') app.installTranslator(appTranslator) # mainWin = MainWindow() mainWin.show() app.exec_() Thorsten ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Fwd: translation of ui
I accidentally mailed below message only to Sebastian, repostion to groups. -- Yönlendirilmiş ileti -- Kimden: Yaşar Arabacı yasar11...@gmail.com Tarih: 01 Temmuz 2011 12:07 Konu: Re: [PyQt] translation of ui Kime: Sebastian Wiesner lunary...@googlemail.com Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. I created a language file and translated it, but how would my application use that translation file? 01 Temmuz 2011 11:44 tarihinde Sebastian Wiesner lunary...@googlemail.comyazdı: 2011/7/1 Yaşar Arabacı yasar11...@gmail.com: Hi, I was wondering how can I generate translation file for a ui generated by QtDesigner. I have no early experience of using translations, so I can't figure it out how to make this work. Should I mark strings in my main module or does QtDesigner somehow provide it for me? You don't need to mark strings in UI files. Just use pylupdate4 on UI files as you would use it on python files, and translations will be extracted from UI files, too. If you load or compile UI files, PyQt generates the necessary code to translate the user interface. Sebastian Wiesner ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
2011/7/1 Yaşar Arabacı yasar11...@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 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
That works like a charm thanks :) 01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner lunary...@googlemail.comyazdı: 2011/7/1 Yaşar Arabacı yasar11...@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 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Fwd: translation of ui
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ı yasar11...@gmail.com yazdı: That works like a charm thanks :) 01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner lunary...@googlemail.com yazdı: 2011/7/1 Yaşar Arabacı yasar11...@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 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt