跳到主要内容
版本:Next

Interface: ILocaleService

molecule.ILocaleService

Implemented by

Methods

addLocales

addLocales(locales): void

Add multiple local languages

Parameters

NameType
localesILocale[]

Returns

void

Defined in

i18n/localeService.ts:37


getCurrentLocale

getCurrentLocale(): undefined | ILocale

Get the current locale language

Returns

undefined | ILocale

Defined in

i18n/localeService.ts:23


getLocale

getLocale(id): undefined | ILocale

Get a locale language by the id

Parameters

NameType
idstring

Returns

undefined | ILocale

Defined in

i18n/localeService.ts:32


getLocales

getLocales(): ILocale[]

Get All locale languages

Returns

ILocale[]

Defined in

i18n/localeService.ts:27


initialize

initialize(locales, localeId): void

Initialize the locales data, and the current locale language,

Parameters

NameType
localesILocale[]
localeIdstring

Returns

void

Defined in

i18n/localeService.ts:14


localize

localize(sourceKey, defaultValue, ...args): string

Returns the international text located by source key,or the default value if it is not find For examples:

localize('id','default value'); // hello ${i}, ${i}
localize('id','default value', 'world'); // hello world, ${i}
localize('id','default value', 'world', 'molecule'); // hello world, molecule

Parameters

NameTypeDescription
sourceKeystringThe key value located in the source international text
defaultValuestringThe default value to be used when not find the international text
...argsstring[]If provided, it will used as the values to be replaced in the international text

Returns

string

Defined in

i18n/localeService.ts:56


onChange

onChange(callback): void

Listen to the local language changed event

Parameters

NameType
callback(prev: ILocale, next: ILocale) => void

Returns

void

Defined in

i18n/localeService.ts:65


removeLocale

removeLocale(id): undefined | ILocale

Remove a locale language by the id

Parameters

NameType
idstring

Returns

undefined | ILocale

Defined in

i18n/localeService.ts:42


reset

reset(): void

Reset the LocaleService to the initial state

Returns

void

Defined in

i18n/localeService.ts:69


setCurrentLocale

setCurrentLocale(id): boolean

Set the current locale language by id

Parameters

NameType
idstring

Returns

boolean

Defined in

i18n/localeService.ts:19