UNPKG

next-intlayer

Version:

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

23 lines (20 loc) 730 B
'use client'; import { useLocale } from "react-intlayer"; import { getLocalizedUrl, getPathWithoutLocale } from "@intlayer/core"; import { useCallback, useMemo } from "react"; import { useRouter } from "next/router.js"; //#region src/client/useLocalePageRouter.ts const useLocalePageRouter = () => { const { push, pathname, reload } = useRouter(); const pathWithoutLocale = useMemo(() => getPathWithoutLocale(pathname), [pathname]); return { ...useLocale({ onLocaleChange: useCallback((locale) => { push(getLocalizedUrl(pathWithoutLocale, locale)); return reload(); }, [pathWithoutLocale]) }), pathWithoutLocale }; }; //#endregion export { useLocalePageRouter }; //# sourceMappingURL=useLocalePageRouter.mjs.map