Commit abb3cdf43ed03d4de98266fefcfa6ebbf260d4a0
1 parent
126beb40
Exists in
master
and in
6 other branches
FIX: Language combo default selection
Showing
1 changed file
with
15 additions
and
5 deletions
Show diff stats
invesalius/i18n.py
... | ... | @@ -44,13 +44,23 @@ def GetLocales(): |
44 | 44 | |
45 | 45 | def GetLocaleOS(): |
46 | 46 | """Return language of the operating system.""" |
47 | + default_locale = 'en' | |
48 | + locales_dict = GetLocales() | |
49 | + | |
47 | 50 | if sys.platform == 'darwin': |
48 | 51 | locale.setlocale(locale.LC_ALL, "") |
49 | - return locale.getlocale()[0] | |
50 | - lc = locale.getdefaultlocale()[0] | |
51 | - if lc: | |
52 | - return lc | |
53 | - return 'en' | |
52 | + os_locale = locale.getlocale()[0] | |
53 | + else: | |
54 | + os_locale = locale.getdefaultlocale()[0] | |
55 | + | |
56 | + if os_locale: | |
57 | + if os_locale in locales_dict.keys(): | |
58 | + default_locale = os_locale | |
59 | + else: | |
60 | + for l in locales_dict: | |
61 | + if l.startswith(os_locale): | |
62 | + default_locale = l | |
63 | + return default_locale | |
54 | 64 | |
55 | 65 | def InstallLanguage(language): |
56 | 66 | language_dir = os.path.abspath(os.path.join('..','locale')) | ... | ... |