Interface: ILocaleService
molecule.ILocaleService
Implemented by
Methods
addLocales
▸ addLocales(locales
): void
Add multiple local languages
Parameters
Name | Type |
---|---|
locales | ILocale [] |
Returns
void
Defined in
getCurrentLocale
▸ getCurrentLocale(): undefined
| ILocale
Get the current locale language
Returns
undefined
| ILocale
Defined in
getLocale
▸ getLocale(id
): undefined
| ILocale
Get a locale language by the id
Parameters
Name | Type |
---|---|
id | string |
Returns
undefined
| ILocale
Defined in
getLocales
▸ getLocales(): ILocale
[]
Get All locale languages
Returns
ILocale
[]
Defined in
initialize
▸ initialize(locales
, localeId
): void
Initialize the locales data, and the current locale language,
Parameters
Name | Type |
---|---|
locales | ILocale [] |
localeId | string |
Returns
void
Defined in
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
Name | Type | Description |
---|---|---|
sourceKey | string | The key value located in the source international text |
defaultValue | string | The default value to be used when not find the international text |
...args | string [] | If provided, it will used as the values to be replaced in the international text |
Returns
string
Defined in
onChange
▸ onChange(callback
): void
Listen to the local language changed event
Parameters
Name | Type |
---|---|
callback | (prev : ILocale , next : ILocale ) => void |
Returns
void
Defined in
removeLocale
▸ removeLocale(id
): undefined
| ILocale
Remove a locale language by the id
Parameters
Name | Type |
---|---|
id | string |
Returns
undefined
| ILocale
Defined in
reset
▸ reset(): void
Reset the LocaleService to the initial state
Returns
void
Defined in
setCurrentLocale
▸ setCurrentLocale(id
): boolean
Set the current locale language by id
Parameters
Name | Type |
---|---|
id | string |
Returns
boolean