Skip to content

gunshi / default / DefaultTranslation

Class: DefaultTranslation ​

Implements ​

  • TranslationAdapter

Constructors ​

Constructor ​

ts
new DefaultTranslation(options): DefaultTranslation;

Parameters ​

ParameterType
optionsTranslationAdapterFactoryOptions

Returns ​

DefaultTranslation

Methods ​

getMessage() ​

ts
getMessage(locale, key): undefined | string;

Get a message of locale.

Parameters ​

ParameterTypeDescription
localestringA Locale at the time of command execution. That is Unicord locale ID (BCP 47)
keystringA key of message resource

Returns ​

undefined | string

A message of locale. if message not found, return undefined.

Implementation of ​

ts
TranslationAdapter.getMessage

getResource() ​

ts
getResource(locale): undefined | Record<string, string>;

Get a resource of locale.

Parameters ​

ParameterTypeDescription
localestringA Locale at the time of command execution. That is Unicord locale ID (BCP 47)

Returns ​

undefined | Record<string, string>

A resource of locale. if resource not found, return undefined.

Implementation of ​

ts
TranslationAdapter.getResource

setResource() ​

ts
setResource(locale, resource): void;

Set a resource of locale.

Parameters ​

ParameterTypeDescription
localestringA Locale at the time of command execution. That is Unicord locale ID (BCP 47)
resourceRecord<string, string>A resource of locale

Returns ​

void

Implementation of ​

ts
TranslationAdapter.setResource

translate() ​

ts
translate(
   locale, 
   key, 
   values): undefined | string;

Translate a message.

Parameters ​

ParameterTypeDescription
localestringA Locale at the time of command execution. That is Unicord locale ID (BCP 47)
keystringA key of message resource
valuesRecord<string, unknown>A values to be resolved in the message

Returns ​

undefined | string

A translated message, if message is not translated, return undefined.

Implementation of ​

ts
TranslationAdapter.translate

Released under the MIT License.