This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/utils/languages_utils.py

29 lines
673 B
Python
Raw Normal View History

import json
import os
import get_path_file
from utils import config_utils
path = os.path.dirname(get_path_file.__file__)
def get_language():
return config_utils.get_in_config("LANGUAGE")
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)
Return english if the language isn't found in the languages.json file
"""
config_json = json.load(open(path + "/config/languages.json", encoding='utf-8', mode='r'))
if name is None:
name = get_language()
if name in config_json:
return config_json.get(name)
return 'english'