Hello Qt Community,
I am rather new to Qt and starting to develop in pyQt.
Works great so far and there is a lot of documentation out there,
but I have a Problem with QLocale not getting the language on my
system right. I have an English Ubuntu with some LC_* set to German.
I am trying to do the following, but this always returns "de_DE", even though LANG, LANGUAGE and LC_CTYPE is set to en_US.utf8
language
= QtCore.
QLocale().
sytem().
name() print language
if appTranslator.load("app_" + language, "./translations"):
app.installTranslator(appTranslator)
language = QtCore.QLocale().sytem().name()
print language
appTranslator = QtCore.QTranslator()
if appTranslator.load("app_" + language, "./translations"):
app.installTranslator(appTranslator)
To copy to clipboard, switch view to plain text mode
Am I doing something wrong? Did somebody have the same Problems? Here is my locale setting:
LANG=en_US.utf8
LANGUAGE=en_US:en
LC_CTYPE=en_US.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=
LANG=en_US.utf8
LANGUAGE=en_US:en
LC_CTYPE=en_US.utf8
LC_NUMERIC=de_DE.utf8
LC_TIME=de_DE.utf8
LC_COLLATE=de_DE.utf8
LC_MONETARY=de_DE.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=de_DE.utf8
LC_NAME=de_DE.utf8
LC_ADDRESS=de_DE.utf8
LC_TELEPHONE=de_DE.utf8
LC_MEASUREMENT=de_DE.utf8
LC_IDENTIFICATION=en_US.utf8
LC_ALL=
To copy to clipboard, switch view to plain text mode
I am working on an Ubuntu 10.04 with pyqt version 4.7.2, libqtcore4 version 4.4.6
For now, as a workaround, I am using functionality from the python standard libary locale. This works on my system, but I don't know about Windows or other systems yet:
import locale
language, encoding = locale.getdefaultlocale(['LANG', 'LC_ALL', 'LANGUAGE', 'LC_MESSAGES', 'LC_CTYPE' ])
import locale
language, encoding = locale.getdefaultlocale(['LANG', 'LC_ALL', 'LANGUAGE', 'LC_MESSAGES', 'LC_CTYPE' ])
To copy to clipboard, switch view to plain text mode
I hope somebody can help. Thanks in advance!
Bookmarks