From a77437873243e0dcffd3e797099d5e2ceb6c3364 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 27 May 2019 16:18:57 +0200 Subject: [PATCH] local must not be None --- tiramisu/i18n.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tiramisu/i18n.py b/tiramisu/i18n.py index c872da7..756a1c0 100644 --- a/tiramisu/i18n.py +++ b/tiramisu/i18n.py @@ -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,