diff --git a/modules/utils.py b/modules/utils.py index 81c1165..c100fb0 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -10,6 +10,7 @@ from sys import exit from os import kill, sep from os import name as osname from traceback import print_exc +from classes.holo_user import HoloUser from modules.logging import logWrite @@ -102,17 +103,19 @@ def configGet(key: str, *args: str, file: str = "config"): this_key = this_key[dict_key] return this_key[key] -def locale(key: str, *args: str, locale: Union[str, User] = configGet("locale")) -> Any: +def locale(key: str, *args: str, locale: Union[str, User, HoloUser] = configGet("locale")) -> Any: """Get value of locale string ### Args: * key (`str`): The last key of the locale's keys path. * *args (`list`): Path to key like: dict[args][key]. - * locale (`Union[str, User]`): Locale to looked up in. Provide User to get his `.language_code`. Defaults to config's locale value. + * locale (`Union[str, User, HoloUser]`): Locale to looked up in. Provide User to get his `.language_code`. Defaults to config's locale value. ### Returns: * any: Value of provided locale key. In normal case must be `str`, `dict` or `list`. """ if isinstance(locale, User): locale = locale.language_code + elif isinstance(locale, HoloUser): + locale = locale.locale if locale is None: locale = configGet("locale")