Skip to content

Locales

LocaleMap dataclass #

LocaleMap(
    _fallback: str,
    da: str | None = None,
    de: str | None = None,
    en_GB: str | None = None,
    en_US: str | None = None,
    es_ES: str | None = None,
    fr: str | None = None,
    hr: str | None = None,
    it: str | None = None,
    lt: str | None = None,
    hu: str | None = None,
    nl: str | None = None,
    no: str | None = None,
    pl: str | None = None,
    pt_BR: str | None = None,
    ro: str | None = None,
    fi: str | None = None,
    sv_SE: str | None = None,
    vi: str | None = None,
    tr: str | None = None,
    cs: str | None = None,
    el: str | None = None,
    bg: str | None = None,
    ru: str | None = None,
    uk: str | None = None,
    hi: str | None = None,
    th: str | None = None,
    zh_CN: str | None = None,
    ja: str | None = None,
    zh_TW: str | None = None,
    ko: str | None = None,
)

Bases: LocaleBuilder

An implementation of crescent.LocaleBuilder that allows you to declare locales as kwargs.

import crescent
from crescent.ext import locales

@bot.include
@crescent.command(name=locales.LocaleMap("fallback", en_US="english-name", fr="french-name"))
async def command(ctx: crescent.Context):
    ...

fallback property #

fallback: str

Return the name used when there is no localization for a language.

build #

build() -> dict[str, str]

Builds the locales for a command. Returns a Mapping of language codes to strings.

Discord API Docs Localization.

i18n #

i18n(fallback: str)

Bases: LocaleBuilder

An implementation of crescent.LocaleBuilder that uses python-i18n.

⚠️ Translations must be loaded before any commands.

import crescent
import i18n
from crescent.ext import locales

i18n.add_translation("name", "translated-name", locale="en")

@bot.include
@crescent.command(name=locales.i18n("name"))
async def command(ctx: crescent.Context):
    ...

fallback property #

fallback: str

Return the name used when there is no localization for a language.

build #

build() -> dict[str, str]

Builds the locales for a command. Returns a Mapping of language codes to strings.

Discord API Docs Localization.