Skip to content

BotLocale

Small addon that can be used by bot clients' classes in order to minimize I/O

_(key, *args, locale=None)

Get value of locale string.

Parameters:

Name Type Description Default
key str

The last key of the locale's keys path.

required
*args str

Path to key like: dict[args][key].

()
locale str | None

Locale to looked up in. Defaults to config's "locale" value.

None

Returns:

Name Type Description
Any Any

Value of provided locale key. Is usually str, dict[str, Any] or list[Any].

__init__(default_locale='en', locales_root=Path('locale'))

Parameters:

Name Type Description Default
default_locale str | None

Default locale. Defaults to "en".

'en'
locales_root str | Path

Path to a directory with locale files. Defaults to Path("locale").

Path('locale')

in_all_locales(key, *args)

Get value of the provided key and path in all available locales.

Parameters:

Name Type Description Default
key str

The last key of the locale's keys path.

required
*args str

Path to key like: dict[args][key].

()

Returns:

Type Description
list[Any]

list[Any]: List of values in all locales.

in_every_locale(key, *args)

Get value of the provided key and path in every available locale with locale tag.

Parameters:

Name Type Description Default
key str

The last key of the locale's keys path.

required
*args str

Path to key like: dict[args][key].

()

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Locale is a key, and it's value from locale file is a value.