Class: I18nService<K>
Type parameters
Name | Type |
---|---|
K | Record <string , unknown > |
Implements
I18nTranslator
<K
>OnModuleDestroy
Constructors
constructor
• new I18nService<K
>(i18nOptions
, translations
, supportedLanguages
, logger
, loader
, languagesSubject
, translationsSubject
)
Type parameters
Name | Type |
---|---|
K | Record <string , unknown > |
Parameters
Name | Type |
---|---|
i18nOptions | I18nOptions |
translations | Observable <I18nTranslation > |
supportedLanguages | Observable <string []> |
logger | Logger |
loader | I18nLoader |
languagesSubject | BehaviorSubject <string []> |
translationsSubject | BehaviorSubject <I18nTranslation > |
Defined in
src/services/i18n.service.ts:44
Properties
i18nOptions
• Protected
Readonly
i18nOptions: I18nOptions
Defined in
src/services/i18n.service.ts:46
languagesSubject
• Private
Readonly
languagesSubject: BehaviorSubject
<string
[]>
Defined in
src/services/i18n.service.ts:54
loader
• Private
Readonly
loader: I18nLoader
Defined in
src/services/i18n.service.ts:52
logger
• Private
Readonly
logger: Logger
Defined in
src/services/i18n.service.ts:51
pluralRules
• Private
pluralRules: Map
<string
, PluralRules
>
Defined in
src/services/i18n.service.ts:40
supportedLanguages
• Private
supportedLanguages: string
[]
Defined in
src/services/i18n.service.ts:38
translations
• Private
translations: I18nTranslation
Defined in
src/services/i18n.service.ts:39
translationsSubject
• Private
Readonly
translationsSubject: BehaviorSubject
<I18nTranslation
>
Defined in
src/services/i18n.service.ts:56
unsubscribe
• Private
unsubscribe: Subject
<void
>
Defined in
src/services/i18n.service.ts:42
Methods
getFallbackLanguage
▸ Private
getFallbackLanguage(lang
): string
Parameters
Name | Type |
---|---|
lang | string |
Returns
string
Defined in
src/services/i18n.service.ts:138
getNestedTranslations
▸ Private
getNestedTranslations(translation
): { args
: any
; index
: number
; key
: string
; length
: number
}[]
Parameters
Name | Type |
---|---|
translation | string |
Returns
{ args
: any
; index
: number
; key
: string
; length
: number
}[]
Defined in
src/services/i18n.service.ts:332
getPluralObject
▸ Private
getPluralObject(translation
): I18nPluralObject
Parameters
Name | Type |
---|---|
translation | any |
Returns
Defined in
src/services/i18n.service.ts:322
getSupportedLanguages
▸ getSupportedLanguages(): string
[]
Returns
string
[]
Defined in
src/services/i18n.service.ts:161
getTranslations
▸ getTranslations(): I18nTranslation
Returns
Defined in
src/services/i18n.service.ts:165
hbsHelper
▸ hbsHelper<P
>(key
, args
, options
): IfAnyOrNever
<PathValue
<K
, P
>, string
, PathValue
<K
, P
>>
Type parameters
Name | Type |
---|---|
P | extends string = any |
Parameters
Name | Type |
---|---|
key | P |
args | any |
options | any |
Returns
IfAnyOrNever
<PathValue
<K
, P
>, string
, PathValue
<K
, P
>>
Defined in
src/services/i18n.service.ts:195
onModuleDestroy
▸ onModuleDestroy(): void
Returns
void
Implementation of
OnModuleDestroy.onModuleDestroy
Defined in
src/services/i18n.service.ts:68
refresh
▸ refresh(translations?
, languages?
): Promise
<void
>
Parameters
Name | Type |
---|---|
translations? | I18nTranslation | Observable <I18nTranslation > |
languages? | string [] | Observable <string []> |
Returns
Promise
<void
>
Defined in
src/services/i18n.service.ts:169
resolveLanguage
▸ resolveLanguage(lang
): string
Parameters
Name | Type |
---|---|
lang | string |
Returns
string
Defined in
src/services/i18n.service.ts:306
t
▸ t<P
, R
>(key
, options?
): IfAnyOrNever
<R
, string
, R
>
Type parameters
Name | Type |
---|---|
P | extends string = any |
R | PathValue <K , P > |
Parameters
Name | Type |
---|---|
key | P |
options? | TranslateOptions |
Returns
IfAnyOrNever
<R
, string
, R
>
Implementation of
Defined in
src/services/i18n.service.ts:154
translate
▸ translate<P
, R
>(key
, options?
): IfAnyOrNever
<R
, string
, R
>
Type parameters
Name | Type |
---|---|
P | extends string = any |
R | PathValue <K , P > |
Parameters
Name | Type |
---|---|
key | P |
options? | TranslateOptions |
Returns
IfAnyOrNever
<R
, string
, R
>
Implementation of
Defined in
src/services/i18n.service.ts:73
translateObject
▸ Private
translateObject(key
, translations
, lang
, options?
, rootTranslations?
): string
| I18nTranslation
Parameters
Name | Type |
---|---|
key | string |
translations | string | I18nTranslation |
lang | string |
options? | TranslateOptions |
rootTranslations? | string | I18nTranslation |
Returns
string
| I18nTranslation
Defined in
src/services/i18n.service.ts:208
validate
▸ validate(value
, options?
): Promise
<ValidationError
[]>
Parameters
Name | Type |
---|---|
value | any |
options? | TranslateOptions |
Returns
Promise
<ValidationError
[]>