i18n-js v5.0.0-alpha.1
    Preparing search index...

    Class Locales

    The registry of locale resolvers. Each I18n instance exposes one as i18n.locales; it maps a locale to the ordered list of locales translations are looked up in (the fallback chain).

    Index
    • Return a list of all locales that must be tried before returning the missing translation message. By default, this will consider the inline option, current locale and fallback locale.

      i18n.locales.get("de-DE");
      // ["de-DE", "de", "en"]

      Parameters

      • locale: string

        The locale query.

      Returns string[]

      The list of locales.

    • You can define custom rules for any locale. Just make sure you return an array containing all locales.

      // Default the Wookie locale to English.
      i18n.locales.register("wk", (_i18n, locale) => {
      return ["en"];
      });

      Parameters

      • locale: string

        The locale's name.

      • localeResolver: string | string[] | LocaleResolver

        The locale resolver strategy.

      Returns void