cal.pub0.org/lib/hooks/useLocale.ts

20 lines
351 B
TypeScript
Raw Normal View History

import { useTranslation } from "next-i18next";
type LocaleProp = {
localeProp: string;
};
export const useLocale = (props: LocaleProp) => {
const { i18n, t } = useTranslation("common");
if (i18n.language !== props.localeProp) {
i18n.changeLanguage(props.localeProp);
}
return {
i18n,
locale: props.localeProp,
t,
};
};