[PyQt] Instant translation on PyQt 4.8.6
Phil Thompson
phil at riverbankcomputing.com
Sat Dec 10 10:47:44 GMT 2011
On Sat, 10 Dec 2011 12:19:19 +0200, admin at mbnoimi.net wrote:
> Hi guys,
>
> I was using the following function for re-translate my application at
> runtime but after compiling my application with new PyQt version it
became
> need to be restarted... do you know what's wrong?
>
> PS
>
> Layout changing works perfectly.
>
> def languageChange(self):
> translator = QTranslator(self)
> currentLangFile = QString(":/l10n/%1.qm").arg(self.getLang())
> if not translator.load(currentLangFile):
> print QString("Couldn't load language file")
> widget = QWidget(self)
> if self.lang == 'ar':
> print 'isAr'
> qApp.setLayoutDirection(Qt.RightToLeft)
> QLocale.setDefault(QLocale(QLocale.Arabic, QLocale.SyrianArabRepublic))
> for widget in qApp.allWidgets():
> widget.setLayoutDirection(Qt.RightToLeft)
> else:
> print 'isEn'
> qApp.setLayoutDirection(Qt.LeftToRight)
> for widget in qApp.allWidgets():
> widget.setLayoutDirection(Qt.LeftToRight)
> qApp.installTranslator(translator)
> self.retranslateUi(self)
I think there might be a pyuic4 regression related to retranslation. What
version were you using that seemed to work?
Can you send me a .ui file that seems to have the problem?
Thanks,
Phil
More information about the PyQt
mailing list