Class I18n

Constructors

Properties

fetcher?: LocaleFetcher

Fetch locale of the specified lang.

lang$: ReadonlyVal<string>

A Val of current lang.

locale$: ReadonlyVal<Locale>

A Val of current locale.

locales$: Val<Locales>

A Val of all loaded locales.

t$: ReadonlyVal<TFunction>

A Val of current translate function.

Accessors

  • get lang(): string
  • Current lang.

    Returns string

Methods

  • Add a locale to the locales.

    Use i18n.locales$.set() for more control.

    Parameters

    Returns void

  • Parameters

    • key: string

    Returns boolean

    — boolean indicating whether a message with the specified key in current language exists or not.

  • Change language.

    Parameters

    • lang: string

    Returns Promise<void>

    — a promise that resolves when the new locale is fetched.

  • Fetch locale of initialLang and return an I18n instance with the locale.

    Parameters

    Returns Promise<I18n>