@embra/i18n - v0.0.4
    Preparing search index...

    Class I18n

    Index

    Constructors

    Properties

    fetcher?: LocaleFetcher

    Fetch locale of the specified lang.

    lang$: Readable<string>

    A Readable of current lang.

    locale$: Readable<Locale>

    A Readable of current locale.

    locales$: Writable<Locales>

    A Writable of all loaded locales.

    t: TFunction = ...

    Translation function that uses the current t$ function.

    A Readable 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>