UNPKG

next-intlayer

Version:

Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.

24 lines (21 loc) 900 B
'use client'; const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); let react_intlayer = require("react-intlayer"); let __intlayer_core = require("@intlayer/core"); let react = require("react"); let next_router_js = require("next/router.js"); //#region src/client/useLocalePageRouter.ts const useLocalePageRouter = () => { const { push, pathname, reload } = (0, next_router_js.useRouter)(); const pathWithoutLocale = (0, react.useMemo)(() => (0, __intlayer_core.getPathWithoutLocale)(pathname), [pathname]); return { ...(0, react_intlayer.useLocale)({ onLocaleChange: (0, react.useCallback)((locale) => { push((0, __intlayer_core.getLocalizedUrl)(pathWithoutLocale, locale)); return reload(); }, [pathWithoutLocale]) }), pathWithoutLocale }; }; //#endregion exports.useLocalePageRouter = useLocalePageRouter; //# sourceMappingURL=useLocalePageRouter.cjs.map