Localization
Class
Translations for command names, descriptions and choices.
from discord_interactions import LocalizationConstructor
Localization(default_locale: str = 'en-US')| Name | Type | Default | Description |
|---|---|---|---|
default_locale | str | 'en-US' |
Methods
load_from_dict
def load_from_dict(data: Dict[str, Dict[str, str]]) -> NoneLoad translations from a dictionary.
load_from_json
def load_from_json(path: str | pathlib.Path) -> NoneLoad translations from a JSON file.
load_from_folder
def load_from_folder(folder: str | pathlib.Path) -> NoneLoad translations from a folder with one JSON file per locale.
get
def get(key: str, locale: str | None = None) -> str | TranslationSetGet a translation or TranslationSet.
t
def t(key: str, locale: str, **kwargs) -> strGet a translated string with formatting.
localizations
def localizations(key: str) -> Dict[str, str]Get the localizations dict for the Discord API.
command
def command(name_key: str, description_key: str) -> Dict[str, Any]Get localization data for a command.
option
def option(name_key: str, description_key: str) -> Dict[str, Any]Get localization data for an option.
choice
def choice(name_key: str) -> Dict[str, Any]Get localization data for a choice.