UNPKG

react-intlayer

Version:

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

28 lines (25 loc) 970 B
'use client'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); const require_getDictionary = require('../getDictionary.cjs'); const require_client_IntlayerProvider = require('./IntlayerProvider.cjs'); let react = require("react"); //#region src/client/useDictionary.ts /** * On the server side, Hook that transform a dictionary and return the content * * If the locale is not provided, it will use the locale from the client context */ const useDictionary = (dictionary, locale) => { const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {}; return (0, react.useMemo)(() => { return require_getDictionary.getDictionary(dictionary, locale ?? currentLocale); }, [ dictionary.key, currentLocale, locale ]); }; //#endregion exports.useDictionary = useDictionary; //# sourceMappingURL=useDictionary.cjs.map