react-intlayer
Version:
Easily internationalize i18n your React applications with type-safe multilingual content management.
29 lines (26 loc) • 987 B
JavaScript
'use client';
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
const require_getIntlayer = require('../getIntlayer.cjs');
let react = require("react");
//#region src/client/useIntlayer.ts
/**
* On the client side, Hook that picking one dictionary by its key and return the content
*
* If the locale is not provided, it will use the locale from the client context
*
* When you need the raw string for attributes like `aria-label`, access the `.value` property of the returned content
*/
const useIntlayer = (key, locale) => {
const { locale: currentLocale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
return (0, react.useMemo)(() => {
return require_getIntlayer.getIntlayer(key, locale ?? currentLocale);
}, [
key,
currentLocale,
locale
]);
};
//#endregion
exports.useIntlayer = useIntlayer;
//# sourceMappingURL=useIntlayer.cjs.map