mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 10:42:58 -03:00
When discovering default locale, default to english if locale.getdefaultlocale() returns None. Also, make locales that include country codes (pt_PT and pt_BR) actually work as default locales
This commit is contained in:
parent
ce2efec610
commit
e6f26f6545
1 changed files with 13 additions and 1 deletions
|
@ -111,7 +111,19 @@ class Settings(object):
|
||||||
|
|
||||||
# Choose the default locale based on the OS preference, and fall-back to English
|
# Choose the default locale based on the OS preference, and fall-back to English
|
||||||
if self._settings['locale'] is None:
|
if self._settings['locale'] is None:
|
||||||
default_locale = locale.getdefaultlocale()[0][:2]
|
language_code, encoding = locale.getdefaultlocale()
|
||||||
|
|
||||||
|
# Default to English
|
||||||
|
if not language_code:
|
||||||
|
language_code = 'en_US'
|
||||||
|
|
||||||
|
if language_code == 'pt_PT' and language_code == 'pt_BR':
|
||||||
|
# Portuguese locales include country code
|
||||||
|
default_locale = language_code
|
||||||
|
else:
|
||||||
|
# All other locales cut off the country code
|
||||||
|
default_locale = language_code[:2]
|
||||||
|
|
||||||
if default_locale not in self.available_locales:
|
if default_locale not in self.available_locales:
|
||||||
default_locale = 'en'
|
default_locale = 'en'
|
||||||
self._settings['locale'] = default_locale
|
self._settings['locale'] = default_locale
|
||||||
|
|
Loading…
Add table
Reference in a new issue