API Reference

Classes

class disnake.ext.fluent.FluentStore(*, strict: bool = False, default_language: str = 'en-US', functions: Dict[str, Callable[[...], ReturnT]] | None = None)

disnake.LocalizationProtocol implementation for Fluent.

Attributes

CACHE_BY_DEFAULT: ClassVar[str]

Controls the default value for cache in l10n(). Does not affect caching of static-by-definition keys like application commands’ names/descriptions. Defaults to False.

Parameters

strict: bool

If True, the store will raise disnake.LocalizationKeyError if a key or locale is not found.

default_language: str

The “fallback” language to use if localization for the desired languages is not found. Defaults to "en-US".

New in version 0.1.0.

get(key: str) Dict[str, str] | None

Localization retriever for disnake. You should use l10n() instead.

Parameters

key: str

The lookup key.

Raises

LocalizationKeyError

No localizations for the provided key were found.

Returns

Optional[Dict[str, str]]

The localizations for the provided key. Returns None if no localizations could be found.

load(path: str | os.PathLike[Any]) None

Initialize all internal attributes.

path must point to a directory structured as per Fluent’s guidelines.

Parameters

path: Union[str, os.PathLike]

The path to the Fluent localization directory to load.

Raises

RuntimeError

The provided path is invalid or couldn’t be loaded

reload() None

Clear localizations and reload all previously loaded FTLs again.

If an exception occurs, the previous data gets restored and the exception is re-raised. See load() for possible raised exceptions.

Not implemented yet.

Fluent Types

class disnake.ext.fluent.FluentBool(value: bool)

Transform boolean value to lowercase string.

Re-exports from fluent.runtime

disnake.ext.fluent.fluent_date(dt: date | datetime | FluentDateType | FluentNone, **kwargs: Any) FluentDateType | FluentNone

See Using fluent.runtime.

disnake.ext.fluent.fluent_number(number: int | float | Decimal | FluentNumber | FluentNone, **kwargs: Any) FluentNumber | FluentNone

See Using fluent.runtime.

class disnake.ext.fluent.FluentDate

See Using fluent.runtime.

class disnake.ext.fluent.FluentDateTime

See Using fluent.runtime.

class disnake.ext.fluent.FluentDecimal(value: int | float | Decimal | FluentNumber, **kwargs: Any)

See Using fluent.runtime.

class disnake.ext.fluent.FluentFloat(value: int | float | Decimal | FluentNumber, **kwargs: Any)

See Using fluent.runtime.

class disnake.ext.fluent.FluentInt(value: int | float | Decimal | FluentNumber, **kwargs: Any)

See Using fluent.runtime.

class disnake.ext.fluent.FluentNone(name: str | None = None)

See Using fluent.runtime.

class disnake.ext.fluent.FluentNumber(value: int | float | Decimal | FluentNumber, **kwargs: Any)

See Using fluent.runtime.