Skip to main content

Class: I18nService<K>

Type parameters

NameType
KRecord<string, unknown>

Implements

Constructors

constructor

new I18nService<K>(i18nOptions, translations, supportedLanguages, logger, loader, languagesSubject, translationsSubject)

Type parameters

NameType
KRecord<string, unknown>

Parameters

NameType
i18nOptionsI18nOptions
translationsObservable<I18nTranslation>
supportedLanguagesObservable<string[]>
loggerLogger
loaderI18nLoader
languagesSubjectBehaviorSubject<string[]>
translationsSubjectBehaviorSubject<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

NameType
langstring

Returns

string

Defined in

src/services/i18n.service.ts:138


getNestedTranslations

Private getNestedTranslations(translation): { args: any ; index: number ; key: string ; length: number }[]

Parameters

NameType
translationstring

Returns

{ args: any ; index: number ; key: string ; length: number }[]

Defined in

src/services/i18n.service.ts:332


getPluralObject

Private getPluralObject(translation): I18nPluralObject

Parameters

NameType
translationany

Returns

I18nPluralObject

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

I18nTranslation

Defined in

src/services/i18n.service.ts:165


hbsHelper

hbsHelper<P>(key, args, options): IfAnyOrNever<PathValue<K, P>, string, PathValue<K, P>>

Type parameters

NameType
Pextends string = any

Parameters

NameType
keyP
argsany
optionsany

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

NameType
translations?I18nTranslation | Observable<I18nTranslation>
languages?string[] | Observable<string[]>

Returns

Promise<void>

Defined in

src/services/i18n.service.ts:169


resolveLanguage

resolveLanguage(lang): string

Parameters

NameType
langstring

Returns

string

Defined in

src/services/i18n.service.ts:306


t

t<P, R>(key, options?): IfAnyOrNever<R, string, R>

Type parameters

NameType
Pextends string = any
RPathValue<K, P>

Parameters

NameType
keyP
options?TranslateOptions

Returns

IfAnyOrNever<R, string, R>

Implementation of

I18nTranslator.t

Defined in

src/services/i18n.service.ts:154


translate

translate<P, R>(key, options?): IfAnyOrNever<R, string, R>

Type parameters

NameType
Pextends string = any
RPathValue<K, P>

Parameters

NameType
keyP
options?TranslateOptions

Returns

IfAnyOrNever<R, string, R>

Implementation of

I18nTranslator.translate

Defined in

src/services/i18n.service.ts:73


translateObject

Private translateObject(key, translations, lang, options?, rootTranslations?): string | I18nTranslation

Parameters

NameType
keystring
translationsstring | I18nTranslation
langstring
options?TranslateOptions
rootTranslations?string | I18nTranslation

Returns

string | I18nTranslation

Defined in

src/services/i18n.service.ts:208


validate

validate(value, options?): Promise<ValidationError[]>

Parameters

NameType
valueany
options?TranslateOptions

Returns

Promise<ValidationError[]>

Implementation of

I18nTranslator.validate

Defined in

src/services/i18n.service.ts:364