react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
15 lines • 506 B
JavaScript
"use client";
import { useContext, useMemo } from "react";
import { getIntlayer } from "../getIntlayer.mjs";
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
const useIntlayer = (key, locale) => {
const { locale: currentLocale } = useContext(IntlayerClientContext);
return useMemo(() => {
const localeTarget = locale ?? currentLocale;
return getIntlayer(key, localeTarget);
}, [key, currentLocale, locale]);
};
export {
useIntlayer
};
//# sourceMappingURL=useIntlayer.mjs.map