lightbulb.localization

class DictLocalizationProvider(localizations: Mapping[Locale, Mapping[str, str]])[source]

Basic localization provider that supplies localizations from a single dictionary.

localizations: Mapping[Locale, Mapping[str, str]]

Mapping containing the localizations that can be provided.

class GnuLocalizationProvider(filename: str, directory: str = 'translations', category: str = 'LC_MESSAGES')[source]

Localization provider that parses localizations from gnu gettext compatible ‘.po’ or ‘.mo’ file paths. This provider expects localizations to be available from the file structure expected by gettext.

I.e. {directory}/{locale}/{category}/{file}.[po|mo] (translations/en-GB/LC_MESSAGES/commands.po)

category: str

The category that the translation file can be found in. Defaults to ‘LC_MESSAGES’.

directory: str

The base directory where the locale directories can be found.

filename: str

The name of the file containing command translations.

localization_unsupported(_: str) NoReturn[source]

Default localization provider. Functions to disable the ability to localize commands and options. If you want to use localized commands in your application you should specify a different built-in or custom localization provider.

Raises:

LocalizationFailedException – Whenever called. This means that when the client attempts to register commands with discord it will cause this error to be thrown if any of the commands (or options) are marked as requiring localization.