478b4ce44e
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
14 lines
352 B
TypeScript
14 lines
352 B
TypeScript
import { useTranslation } from "react-i18next";
|
|
import i18n, { LOCALE_KEY } from "./index";
|
|
|
|
export function useLocale() {
|
|
const { i18n: instance } = useTranslation();
|
|
|
|
const setLocale = (lng: "en" | "sv") => {
|
|
localStorage.setItem(LOCALE_KEY, lng);
|
|
void i18n.changeLanguage(lng);
|
|
};
|
|
|
|
return { locale: instance.language, setLocale };
|
|
}
|