Skip to content

i18nPlugin

Defined in: plugins/i18nPlugin.ts:71

i18n module class.

Extends

Implements

Constructors

new i18nPlugin()

new i18nPlugin(id): i18nPlugin

Defined in: plugins/Plugin.ts:40

Parameters

id

string = 'Plugin'

Returns

i18nPlugin

Inherited from

Plugin.constructor

Properties

__dill_pixel_method_binding_root

__dill_pixel_method_binding_root: boolean

Defined in: plugins/Plugin.ts:37

Inherited from

Plugin.__dill_pixel_method_binding_root


id

readonly id: "i18n" = 'i18n'

Defined in: plugins/i18nPlugin.ts:72

Implementation of

Ii18nPlugin.id

Overrides

Plugin.id


onLocaleChanged

onLocaleChanged: Signal<(locale) => void>

Defined in: plugins/i18nPlugin.ts:73

Implementation of

Ii18nPlugin.onLocaleChanged

Accessors

app

Get Signature

get app(): T

Defined in: plugins/Plugin.ts:45

Returns

T

Implementation of

Ii18nPlugin.app

Inherited from

Plugin.app


locale

Get Signature

get locale(): string

Defined in: plugins/i18nPlugin.ts:83

Getter for locale.

Returns

string

Implementation of

Ii18nPlugin.locale


locales

Get Signature

get locales(): string[]

Defined in: plugins/i18nPlugin.ts:87

Returns

string[]

Implementation of

Ii18nPlugin.locales

Methods

addSignalConnection()

addSignalConnection(…args): void

Defined in: plugins/Plugin.ts:71

Add signal connections to the container.

Parameters

args

SignalConnection[]

The signal connections to add.

Returns

void

Implementation of

Ii18nPlugin.addSignalConnection

Inherited from

Plugin.addSignalConnection


clearSignalConnections()

clearSignalConnections(): void

Defined in: plugins/Plugin.ts:77

Returns

void

Implementation of

Ii18nPlugin.clearSignalConnections

Inherited from

Plugin.clearSignalConnections


destroy()

destroy(): void

Defined in: plugins/Plugin.ts:49

Returns

void

Implementation of

Ii18nPlugin.destroy

Inherited from

Plugin.destroy


initialize()

initialize(app, options): Promise<void>

Defined in: plugins/i18nPlugin.ts:98

Initializes the i18n module. sets the default locale and loads the locale files.

Parameters

app

IApplication

The application instance.

options

Partial<i18nOptions>

The i18n options.

Returns

Promise<void>

Promise

Implementation of

Ii18nPlugin.initialize

Overrides

Plugin.initialize


loadLocale()

loadLocale(localeId): Promise<void>

Defined in: plugins/i18nPlugin.ts:222

Loads a locale.

Parameters

localeId

string

The locale id to load.

Returns

Promise<void>

Promise

Implementation of

Ii18nPlugin.loadLocale


parse()

parse(input, locale): string

Defined in: plugins/i18nPlugin.ts:198

Parses the input string and replaces anything in between {} braces, assuming it is a key in the dictionary.

Parameters

input

string

locale

string = ...

Returns

string

Implementation of

Ii18nPlugin.parse


postInitialize()

postInitialize(_app): void | Promise<void>

Defined in: plugins/Plugin.ts:60

Parameters

_app

IApplication

Returns

void | Promise<void>

Implementation of

Ii18nPlugin.postInitialize

Inherited from

Plugin.postInitialize


setLocale()

setLocale(localeId): Promise<string>

Defined in: plugins/i18nPlugin.ts:119

Sets the locale. If the locale is not loaded, it will load it first.

Parameters

localeId

string

The locale id to set.

Returns

Promise<string>

Promise

Implementation of

Ii18nPlugin.setLocale


t()

t(key, params?, locale?): string

Defined in: plugins/i18nPlugin.ts:137

Translates a key into a string. If the key is not found, it will return an empty string. If the key is found, it will replace any placeholders in the string with the values from the params object. If the key contains a variant, it will select a random variant if the variant param is set to ‘random’. If the key contains a number variant, it will select the variant based on the variant param.

Parameters

key

string

The key to translate.

params?

i18nTParams

The parameters to replace in the string.

locale?

string = ...

The locale to use for translation.

Returns

string

The translated string.

Implementation of

Ii18nPlugin.t


translate()

translate(key, params?, locale?): string

Defined in: plugins/i18nPlugin.ts:188

Translates a key into a string (alias for t)

Parameters

key

string

The key to translate.

params?

i18nTParams

The parameters to replace in the string.

locale?

string = ...

The locale to use for translation.

Returns

string

The translated string.