@univerjs/core v0.5.0-beta.1 • Docs
Class: LocaleService
This service provides i18n and timezone / location features to other modules.
Extends
Constructors
new LocaleService()
new LocaleService(): LocaleService
Returns
Overrides
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:36
Properties
Property | Modifier | Type | Default value | Inherited from | Defined in |
---|---|---|---|---|---|
_disposed | protected | boolean | false | Disposable ._disposed | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:93 |
currentLocale$ | readonly | Observable <LocaleType > | undefined | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:29 |
localeChanged$ | public | Subject <void > | undefined | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:34 |
Methods
dispose()
dispose(): void
Returns
void
Inherited from
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:106
disposeWithMe()
disposeWithMe(disposable): IDisposable
Parameters
Parameter | Type |
---|---|
disposable | DisposableLike |
Returns
Inherited from
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96
ensureNotDisposed()
protected ensureNotDisposed(): void
Returns
void
Inherited from
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:100
getCurrentLocale()
getCurrentLocale(): LocaleType
Returns
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:101
getLocales()
getLocales(): undefined | ILanguagePack
Returns
undefined
| ILanguagePack
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:97
load()
load(locales): void
Load more locales after init.
Parameters
Parameter | Type | Description |
---|---|---|
locales | ILocales | Locale object |
Returns
void
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:47
resolveKeyPath()
resolveKeyPath(obj, keys): null | LanguageValue
Parameters
Parameter | Type |
---|---|
obj | ILanguagePack |
keys | string [] |
Returns
null
| LanguageValue
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:105
setLocale()
setLocale(locale): void
Parameters
Parameter | Type |
---|---|
locale | LocaleType |
Returns
void
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:92
t()
t(key, ...args): string
Translate a key to the current locale
Parameters
Parameter | Type | Description |
---|---|---|
key | string | the key to translate |
…args | string [] | optional arguments to replace in the translated string |
Returns
string
the translated string
Examples
const locales = {
[LocaleType.EN_US]: {
foo: {
bar: 'Hello'
}
}
t('foo.bar') => 'Hello'
const locales = {
[LocaleType.EN_US]: {
foo: {
bar: 'Hello {0}'
}
}
t('foo.bar', 'World') => 'Hello World'
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/core/src/services/locale/locale.service.ts:76