]> git.lizzy.rs Git - torbrowser-launcher.git/commitdiff
Set language from LC_MESSAGES, not LC_CTYPE
authorKarl-Johan Karlsson <creideiki@ferretporn.se>
Mon, 12 Oct 2020 16:17:00 +0000 (18:17 +0200)
committerKarl-Johan Karlsson <creideiki@ferretporn.se>
Mon, 12 Oct 2020 16:17:00 +0000 (18:17 +0200)
Calling `locale.getlocale()` checks LC_CTYPE, which is not meant for
UI strings. Change the call to check LC_MESSAGES instead.

Also call `locale.setlocale()` first to import the locale settings
from the environment. This is not needed for LC_CTYPE due to
https://bugs.python.org/issue6203 but is required for LC_MESSAGES.

Closes #361

torbrowser_launcher/common.py

index 1a05fb48d80baabaafacb0dd786da2ea00e893d7..94ae39c9ae4db06fdadb06cd8c704d0eb4fcac3b 100644 (file)
@@ -100,7 +100,8 @@ class Common(object):
             "zh-CN",
             "zh-TW",
         ]
-        default_locale = locale.getlocale()[0]
+        locale.setlocale(locale.LC_MESSAGES, '')
+        default_locale = locale.getlocale(locale.LC_MESSAGES)[0]
         if default_locale is None:
             self.language = "en-US"
         else: