Small refactor is made
This commit is contained in:
parent
dc760a8b67
commit
ce0503500a
@ -31,7 +31,7 @@ async def _(key: str, *args: str, locale: str = sync.config_get("locale")) -> An
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except FileNotFoundError:
|
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
|
this_key = this_dict
|
||||||
for dict_key in args:
|
for dict_key in args:
|
||||||
@ -40,7 +40,7 @@ async def _(key: str, *args: str, locale: str = sync.config_get("locale")) -> An
|
|||||||
try:
|
try:
|
||||||
return this_key[key]
|
return this_key[key]
|
||||||
except KeyError:
|
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:
|
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 = []
|
output = []
|
||||||
valid_locales = []
|
|
||||||
|
|
||||||
files_locales = listdir(await config_get("locale", "locations"))
|
files_locales = listdir(await config_get("locale", "locations"))
|
||||||
|
|
||||||
for entry in files_locales:
|
valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales]
|
||||||
valid_locales.append(".".join(entry.split(".")[:-1]))
|
|
||||||
|
|
||||||
for lc in valid_locales:
|
for lc in valid_locales:
|
||||||
try:
|
try:
|
||||||
this_dict = await json_read(
|
this_dict = await json_read(
|
||||||
|
Loading…
Reference in New Issue
Block a user