Locale encoding fixes
On non-Windows, setlocale will try both normalised and preferred encoding.
This commit is contained in:
parent
6dff105a5b
commit
e353af3195
|
@ -105,16 +105,20 @@ def change_translation(locale):
|
||||||
QtGui.QApplication.installTranslator(qsystranslator)
|
QtGui.QApplication.installTranslator(qsystranslator)
|
||||||
|
|
||||||
lang = pythonlocale.normalize(l10n.getTranslationLanguage())
|
lang = pythonlocale.normalize(l10n.getTranslationLanguage())
|
||||||
|
langs = [lang.split(".")[0] + "." + l10n.encoding, lang]
|
||||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||||
lang = l10n.getWindowsLocale(lang)
|
langs = [l10n.getWindowsLocale(lang)]
|
||||||
try:
|
for lang in langs:
|
||||||
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
try:
|
||||||
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
||||||
l10n.encoding = pythonlocale.nl_langinfo(pythonlocale.CODESET)
|
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
||||||
else:
|
l10n.encoding = pythonlocale.nl_langinfo(pythonlocale.CODESET)
|
||||||
l10n.encoding = pythonlocale.getlocale()[1]
|
else:
|
||||||
except:
|
l10n.encoding = pythonlocale.getlocale()[1]
|
||||||
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
logger.info("Successfully set locale to %s", lang)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||||
|
|
||||||
class MyForm(settingsmixin.SMainWindow):
|
class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user