UNPKG

react-intlayer

Version:

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

27 lines (24 loc) 895 B
'use client'; const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); const require_client_IntlayerProvider = require('./IntlayerProvider.cjs'); const require_getDictionary = require('../getDictionary.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, currentLocale, locale ]); }; //#endregion exports.useDictionary = useDictionary; //# sourceMappingURL=useDictionary.cjs.map