UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

19 lines 694 B
"use client"; import { useChangedContent } from "@intlayer/editor-react"; import { useContext } from "react"; import { getDictionary } from "../getDictionary.mjs"; import { getIntlayer } from "../getIntlayer.mjs"; import { IntlayerClientContext } from "./IntlayerProvider.mjs"; const useIntlayer = (key, locale) => { const { locale: currentLocale } = useContext(IntlayerClientContext); const { changedContent } = useChangedContent(); const localeTarget = locale ?? currentLocale; if (changedContent?.[key]) { return getDictionary(changedContent?.[key], localeTarget); } return getIntlayer(key, localeTarget); }; export { useIntlayer }; //# sourceMappingURL=useIntlayer.mjs.map