local must not be None

This commit is contained in:
Emmanuel Garette 2019-05-27 16:18:57 +02:00
parent 5498a12b2b
commit a774378732

View file

@ -24,6 +24,9 @@ from pkg_resources import resource_filename
from .log import log
DEFAULT = 'en'
def get_translation() -> str:
"""Sets the user locale as langage
The default is set to english
@ -40,11 +43,14 @@ def get_translation() -> str:
from locale import getdefaultlocale
default_locale = getdefaultlocale()
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:
user_locale = default_locale[:2]
else:
user_locale = 'en'
user_locale = DEFAULT
try:
trans = translation(domain=app_name,
localedir=translations_path,