local must not be None
This commit is contained in:
parent
5498a12b2b
commit
a774378732
1 changed files with 8 additions and 2 deletions
|
@ -24,6 +24,9 @@ from pkg_resources import resource_filename
|
||||||
from .log import log
|
from .log import log
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT = 'en'
|
||||||
|
|
||||||
|
|
||||||
def get_translation() -> str:
|
def get_translation() -> str:
|
||||||
"""Sets the user locale as langage
|
"""Sets the user locale as langage
|
||||||
The default is set to english
|
The default is set to english
|
||||||
|
@ -40,11 +43,14 @@ def get_translation() -> str:
|
||||||
from locale import getdefaultlocale
|
from locale import getdefaultlocale
|
||||||
default_locale = getdefaultlocale()
|
default_locale = getdefaultlocale()
|
||||||
if default_locale and isinstance(default_locale, tuple):
|
if default_locale and isinstance(default_locale, tuple):
|
||||||
user_locale = default_locale[0][:2]
|
if default_locale[0] is not None:
|
||||||
|
user_locale = default_locale[0][:2]
|
||||||
|
else:
|
||||||
|
user_locale = DEFAULT
|
||||||
elif default_locale:
|
elif default_locale:
|
||||||
user_locale = default_locale[:2]
|
user_locale = default_locale[:2]
|
||||||
else:
|
else:
|
||||||
user_locale = 'en'
|
user_locale = DEFAULT
|
||||||
try:
|
try:
|
||||||
trans = translation(domain=app_name,
|
trans = translation(domain=app_name,
|
||||||
localedir=translations_path,
|
localedir=translations_path,
|
||||||
|
|
Loading…
Reference in a new issue