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
|
||||
|
||||
|
||||
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):
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue