From 719c472f23490dfe039327743f4553f600c799a9 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Mon, 15 Sep 2014 17:52:57 -0300 Subject: Improve support for RTL languages. * Update transifex resource name. * Use RightToLeft layout for Arabic language. * Use better names and comments on i18n section. * Use unicode to initialize widgets with text that otherwise (str) will fail when Arabic (and most likely any other language with non-ascii characters) is used. Closes #5289, #6033. --- src/leap/bitmask/frontend_app.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/leap/bitmask/frontend_app.py') diff --git a/src/leap/bitmask/frontend_app.py b/src/leap/bitmask/frontend_app.py index 5ea89fc9..909005f0 100644 --- a/src/leap/bitmask/frontend_app.py +++ b/src/leap/bitmask/frontend_app.py @@ -76,15 +76,24 @@ def run_frontend(options, flags_dict, backend_pid): qApp = QtGui.QApplication(sys.argv) - # To test: - # $ LANG=es ./app.py - locale = QtCore.QLocale.system().name() - qtTranslator = QtCore.QTranslator() - if qtTranslator.load("qt_%s" % locale, ":/translations"): - qApp.installTranslator(qtTranslator) - appTranslator = QtCore.QTranslator() - if appTranslator.load("%s.qm" % locale[:2], ":/translations"): - qApp.installTranslator(appTranslator) + # To test the app in other language you can do: + # shell> LANG=es bitmask + # or in some rare case if the code above didn't work: + # shell> LC_ALL=es LANG=es bitmask + locale = QtCore.QLocale.system().name() # en_US, es_AR, ar_SA, etc + locale_short = locale[:2] # en, es, ar, etc + rtl_languages = ('ar', ) # right now tested on 'arabic' only. + + systemQtTranslator = QtCore.QTranslator() + if systemQtTranslator.load("qt_%s" % locale, ":/translations"): + qApp.installTranslator(systemQtTranslator) + + bitmaskQtTranslator = QtCore.QTranslator() + if bitmaskQtTranslator.load("%s.qm" % locale_short, ":/translations"): + qApp.installTranslator(bitmaskQtTranslator) + + if locale_short in rtl_languages: + qApp.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) # Needed for initializing qsettings it will write # .config/leap/leap.conf top level app settings in a platform -- cgit v1.2.3