Changed imports
This commit is contained in:
parent
723cc40221
commit
783443e448
@ -2,7 +2,8 @@ from os import listdir
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Union
|
||||
|
||||
from libbot import config_get, json_read, sync
|
||||
import libbot
|
||||
from libbot.i18n import sync
|
||||
from libbot.i18n.classes.bot_locale import BotLocale
|
||||
|
||||
|
||||
@ -23,14 +24,14 @@ async def _(
|
||||
### Returns:
|
||||
* `Any`: Value of provided locale key. Is usually `str`, `dict` or `list`
|
||||
"""
|
||||
locale = sync.config_get("locale") if locale is None else locale
|
||||
locale = libbot.sync.config_get("locale") if locale is None else locale
|
||||
|
||||
try:
|
||||
this_dict = await json_read(Path(f"{locales_root}/{locale}.json"))
|
||||
this_dict = await libbot.json_read(Path(f"{locales_root}/{locale}.json"))
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
this_dict = await json_read(
|
||||
Path(f'{locales_root}/{await config_get("locale")}.json')
|
||||
this_dict = await libbot.json_read(
|
||||
Path(f'{locales_root}/{await libbot.config_get("locale")}.json')
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return f'⚠️ Locale in config is invalid: could not get "{key}" in {args} from locale "{locale}"'
|
||||
@ -65,7 +66,7 @@ async def in_all_locales(
|
||||
valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales]
|
||||
for lc in valid_locales:
|
||||
try:
|
||||
this_dict = await json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
this_dict = await libbot.json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
@ -101,7 +102,7 @@ async def in_every_locale(
|
||||
valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales]
|
||||
for lc in valid_locales:
|
||||
try:
|
||||
this_dict = await json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
this_dict = await libbot.json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
|
@ -2,8 +2,7 @@ from os import listdir
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Union
|
||||
|
||||
from libbot import sync
|
||||
from libbot.sync import config_get, json_read
|
||||
import libbot
|
||||
|
||||
|
||||
def _(
|
||||
@ -24,13 +23,15 @@ def _(
|
||||
* `Any`: Value of provided locale key. Is usually `str`, `dict` or `list`
|
||||
"""
|
||||
if locale is None:
|
||||
locale = sync.config_get("locale")
|
||||
locale = libbot.sync.config_get("locale")
|
||||
|
||||
try:
|
||||
this_dict = json_read(Path(f"{locales_root}/{locale}.json"))
|
||||
this_dict = libbot.sync.json_read(Path(f"{locales_root}/{locale}.json"))
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
this_dict = json_read(Path(f'{locales_root}/{config_get("locale")}.json'))
|
||||
this_dict = libbot.sync.json_read(
|
||||
Path(f'{locales_root}/{libbot.sync.config_get("locale")}.json')
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return f'⚠️ Locale in config is invalid: could not get "{key}" in {args} from locale "{locale}"'
|
||||
|
||||
@ -64,7 +65,7 @@ def in_all_locales(
|
||||
valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales]
|
||||
for lc in valid_locales:
|
||||
try:
|
||||
this_dict = json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
this_dict = libbot.sync.json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
@ -100,7 +101,7 @@ def in_every_locale(
|
||||
valid_locales = [".".join(entry.split(".")[:-1]) for entry in files_locales]
|
||||
for lc in valid_locales:
|
||||
try:
|
||||
this_dict = json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
this_dict = libbot.sync.json_read(Path(f"{locales_root}/{lc}.json"))
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user