UNPKG

react-intlayer

Version:

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

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