Locale encoding fixes
On non-Windows, setlocale will try both normalised and preferred encoding.
This commit is contained in:
parent
6dff105a5b
commit
e353af3195
|
@ -105,14 +105,18 @@ 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)]
|
||||||
|
for lang in langs:
|
||||||
try:
|
try:
|
||||||
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
pythonlocale.setlocale(pythonlocale.LC_ALL, lang)
|
||||||
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
if 'win32' not in sys.platform and 'win64' not in sys.platform:
|
||||||
l10n.encoding = pythonlocale.nl_langinfo(pythonlocale.CODESET)
|
l10n.encoding = pythonlocale.nl_langinfo(pythonlocale.CODESET)
|
||||||
else:
|
else:
|
||||||
l10n.encoding = pythonlocale.getlocale()[1]
|
l10n.encoding = pythonlocale.getlocale()[1]
|
||||||
|
logger.info("Successfully set locale to %s", lang)
|
||||||
|
break
|
||||||
except:
|
except:
|
||||||
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
logger.error("Failed to set locale to %s", lang, exc_info=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user