Variable detectLocaleConst

detectLocale: {
    cacheUserLanguage: (lng: string) => void;
    detect: () => string;
    type: "languageDetector";
} = ...

Language detector plugin for i18next

Must call initLocale before initializaing i18next

This also sets the global locale state whenever i18next.changeLanguage is called.

Example

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

initLocale({ supported: ["en", "es"], default: "en", persist: true });

i18next.use(detectLocale).init({
// don't need to specify `lng` here

// ...other options not shown
});

Type declaration

  • cacheUserLanguage: (lng: string) => void
  • detect: () => string
  • type: "languageDetector"