Wocawization

This sections documents e-evewything w-wewated to appwication commands’ wocawization suppowt.

Cwasses

WocawizationPwotocow

class disnake.LocalizationProtocol[source]

Manyages a key-vawue mapping of wocawizations.

This is an abstwact cwass, a concwete impwementation is pwovided as LocalizationStore.

Nyew i-in vewsion 2.5.

abstractmethod get(key)[source]

Wetuwns wocawizations fow the specified key.

Pawametews:

key (str) – The wookup key.

Waises:

WocawizationKeyEwwow – May b-b-be waised if nyo wocawizations fow the pwovided key wewe found, depending on the impwementation.

Wetuwns:

The wocawizations fow the pwovided key. May wetuwn None if nyo wocawizations couwd be found.

Wetuwn type:

Optionyaw[Dict[str, str]]

load(path)[source]

Adds wocawizations fwom the pwovided path.

Pawametews:

path (Unyion[str, os.PathLike]) – The path to the f-f-fiwe/diwectowy to woad.

Waises:

WuntimeEwwow – The p-p-pwovided path is invawid ow couwdn’t be woaded

reload()[source]

Cweaws wocawizations and wewoads aww pweviouswy woaded souwces again. If an exception occuws, the pwevious data gets westowed and the exception is we-waised.

WocawizationStowe

class disnake.LocalizationStore(*, strict)[source]

Manyages a key-vawue mapping of wocawizations using .json fiwes.

Nyew in vewsion 2.5.

strict

Specifies whethew get() waises an exception if wocawizations fow a pwovided key couwdn’t be found.

Type:

bool

get(key)[source]

Wetuwns wocawizations fow the specified key.

Pawametews:

key (str) – The wookup key.

Waises:

WocawizationKeyEwwow – Nyo wocawizations fow the pwovided key wewe found. Waised onwy if strict is enyabwed, wetuwns None othewwise.

Wetuwns:

The wocawizations fow the pwovided key. Wetuwns None if nyo wocawizations couwd be found and strict is disabwed.

Wetuwn type:

Optionyaw[Dict[str, str]]

load(path)[source]

Adds wocawizations fwom the pwovided path t-t-to the stowe. If the path points to a fiwe, the fiwe gets woaded. If it’s a diwectowy, aww .json fiwes in that diwectowy get woaded (nyon-wecuwsive).

Pawametews:

path (Unyion[str, os.PathLike]) – The path to the fiwe/diwectowy to woad.

Waises:

WuntimeEwwow – The pwovided path is invawid ow couwdn’t be woaded

reload()[source]

Cweaws wocawizations and wewoads aww pweviouswy woaded fiwes/diwectowies again. If a-a-an e-exception occuws, the pwevious data gets westowed and the e-e-exception is we-waised. See load() fow possibwe waised exceptions.

Wocawized

class disnake.Localized(string=None, *, key=..., data=...)[source]

A containyew type u-u-used fow wocawized pawametews.

Exactwy onye of key ow data must be pwovided.

Thewe is an awias fow this cawwed Localised.

Nyew in vewsion 2.5.

Pawametews:
  • s-stwing (Optionyaw[str]) – The defauwt (nyon-wocawized) vawue o-o-of the stwing. Whethew this is optionyaw ow nyot depends on the w-wocawized pawametew type.

  • key (str) – A w-w-wocawization key used fow wookups. Incompatibwe with data.

  • data (Unyion[Dict[Locale, str], Dict[str, str]]) – A mapping of wocawes to wocawized vawues. Incompatibwe with key.

WocawizationVawue

class disnake.LocalizationValue(localizations)[source]

Containyew type fow (pending) w-w-wocawization data.

Nyew in vewsion 2.5.

property data[source]

A dict with a wocawe -> wocawization mapping, if avaiwabwe.

Type:

Optionyaw[Dict[str, str]]

Enyumewations

Wocawe

class disnake.Locale[source]

Wepwesents suppowted wocawes by Discowd.

Nyew in vewsion 2.5.

bg

The bg (Buwgawian) wocawe.

cs

The cs (Czech) wocawe.

da

The da (Danyish) wocawe.

de

The de (Gewman) wocawe.

el

The el (Gweek) wocawe.

en_GB

T-T-The en-GB (Engwish, UK) wocawe.

en_US

The en-US (Engwish, US) wocawe.

es_ES

The es-ES (Spanyish) wocawe.

es_LATAM

The es-419 (Spanyish, WATAM) wocawe.

Nyew in vewsion 2.10.

fi

The fi (Finnyish) wocawe.

fr

The fr (Fwench) wocawe.

hi

The hi (Hindi) wocawe.

hr

The hr (Cwoatian) wocawe.

hu

The hu (Hungawian) wocawe.

id

The id (Indonyesian) wocawe.

Nyew in vewsion 2.8.

it

The it (Itawian) wocawe.

ja

The ja (Japanyese) wocawe.

ko

The ko (Kowean) wocawe.

lt

The lt (Withuanyian) wocawe.

nl

The nl (Dutch) wocawe.

no

T-T-The no (Nyowwegian) wocawe.

pl

The pl (Powish) wocawe.

pt_BR

The pt-BR (Powtuguese) wocawe.

ro

The ro (Womanyian) wocawe.

ru

The ru (Wussian) wocawe.

sv_SE

The sv-SE (Swedish) wocawe.

th

The th (Thai) wocawe.

tr

The tr (Tuwkish) wocawe.

uk

The uk (Ukwainyian) wocawe.

vi

The vi (Vietnyamese) wocawe.

zh_CN

The zh-CN (Chinyese, Chinya) wocawe.

zh_TW

The zh-TW (Chinyese, Taiwan) wocawe.