Set the language at any time, from anywhere.

evtLang enable you to switch the language without using useLang that can only be used in a react component.

import { $lang } from "i18n";

    ()=> {
        console.log(`The app is currently in ${evtLang.state}`);
        console.log("We switch to fr now!");
        //This will trigger components to re-render.
        $lang.current= "fr";

Have a global callback that is invoked whenever the language is changed.

import { $lang } from "i18n";

    .subscribe(lang=> console.log(`The app has just beed switched to ${lang}`));

Last updated