From e50a411a492cdad467c49ebe257facd89db31d96 Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Fri, 30 Jul 2021 21:11:49 +0200 Subject: [PATCH] added method to get only a language country code (fr for fr-fr, etc) --- jarvis/utils/languages_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jarvis/utils/languages_utils.py b/jarvis/utils/languages_utils.py index 47fd563..fda9c4b 100644 --- a/jarvis/utils/languages_utils.py +++ b/jarvis/utils/languages_utils.py @@ -11,6 +11,14 @@ def get_language(): return config_utils.get_in_config("LANGUAGE") +def get_language_only_country(): + """ + Returns something like "fr" for "fr-fr" in config or "en" for "en-us" + :return: language's country initials + """ + return get_language().split("-")[0] + + def get_language_full_name(name=None): """ Return for exemple french for fr-fr, english for en-en, etc (savec in languages.json in the config folder)