Skip to main content

Class: I18nContext<K>

Type parameters

NameType
KRecord<string, unknown>

Implements

Constructors

constructor

new I18nContext<K>(lang, service)

Type parameters

NameType
KRecord<string, unknown>

Parameters

NameType
langstring
serviceI18nService<K>

Defined in

src/i18n.context.ts:19

Properties

id

Readonly id: number

Defined in

src/i18n.context.ts:13


lang

Readonly lang: string

Defined in

src/i18n.context.ts:20


service

Readonly service: I18nService<K>

Defined in

src/i18n.context.ts:21


counter

Static Private counter: number = 1

Defined in

src/i18n.context.ts:12


storage

Static Private storage: AsyncLocalStorage<I18nContext<Record<string, unknown>>>

Defined in

src/i18n.context.ts:11

Accessors

i18n

get i18n(): I18nContext<K>

Returns

I18nContext<K>

Defined in

src/i18n.context.ts:15

Methods

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/i18n.context.ts:35


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/i18n.context.ts:24


validate

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

Parameters

NameType
valueany
options?TranslateOptions

Returns

Promise<ValidationError[]>

Implementation of

I18nTranslator.validate

Defined in

src/i18n.context.ts:42


create

Static create(ctx, next): void

Parameters

NameType
ctxI18nContext<Record<string, unknown>>
next(...args: any[]) => void

Returns

void

Defined in

src/i18n.context.ts:53


createAsync

Static createAsync<T>(ctx, next): Promise<T>

Type parameters

Name
T

Parameters

NameType
ctxI18nContext<Record<string, unknown>>
next(...args: any[]) => Promise<T>

Returns

Promise<T>

Defined in

src/i18n.context.ts:57


current

Static current<K>(context?): I18nContext<K>

Type parameters

NameType
KRecord<string, unknown>

Parameters

NameType
context?ArgumentsHost

Returns

I18nContext<K>

Defined in

src/i18n.context.ts:64