pure
    Preparing search index...
    • Initialize Locale utilities

      initLocale must be called before using the other functions.

      import { initLocale } from "@pistonite/pure/pref";

      initLocale({
      // required
      supported: ["en", "zh-CN", "zh-TW"] as const,
      default: "en",

      // optional
      persist: true, // save to localStorage
      initial: "en-US", // initial value, instead of detecting
      });

      The @pistonite/pure-i18next package provides additional wrapper for connecting with i18next. See the documentation there for more details. You will use initLocaleWithI18next instead of initLocale.

      A React hook is provided in the pure-react package to get the current locale from React components.

      Changing the locale from React components is the same as from outside React, with setLocale or i18next.changeLanguage, depending on your setup.

      Type Parameters

      • TLocale extends string

      Parameters

      Returns void