From ce0503500a5a964d7c6d8b3175a881a2cbe6c708 Mon Sep 17 00:00:00 2001 From: profitroll Date: Fri, 26 May 2023 13:02:09 +0200 Subject: [PATCH] Small refactor is made --- libbot/i18n/__init__.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libbot/i18n/__init__.py b/libbot/i18n/__init__.py index cb013ab..5066a0d 100644 --- a/libbot/i18n/__init__.py +++ b/libbot/i18n/__init__.py @@ -31,7 +31,7 @@ async def _(key: str, *args: str, locale: str = sync.config_get("locale")) -> An ) ) except FileNotFoundError: - return f'⚠️ Locale in config is invalid: could not get "{key}" in {str(args)} from locale "{locale}"' + return f'⚠️ Locale in config is invalid: could not get "{key}" in {args} from locale "{locale}"' this_key = this_dict for dict_key in args: @@ -40,7 +40,7 @@ async def _(key: str, *args: str, locale: str = sync.config_get("locale")) -> An try: return this_key[key] except KeyError: - return f'⚠️ Locale in config is invalid: could not get "{key}" in {str(args)} from locale "{locale}"' + return f'⚠️ Locale in config is invalid: could not get "{key}" in {args} from locale "{locale}"' async def in_all_locales(key: str, *args: str) -> list: @@ -55,13 +55,9 @@ async def in_all_locales(key: str, *args: str) -> list: """ output = [] - valid_locales = [] - files_locales = listdir(await config_get("locale", "locations")) - for entry in files_locales: - valid_locales.append(".".join(entry.split(".")[:-1])) - + valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales] for lc in valid_locales: try: this_dict = await json_read(