Skip to main content
Glama
useLocalePageRouter.ts883 B
'use client'; import { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core'; import type { LocalesValues } from '@intlayer/types'; import { useRouter } from 'next/router.js'; import { useCallback, useMemo } from 'react'; import { useLocale as useLocaleReact } from 'react-intlayer'; export const useLocalePageRouter = () => { const { push, pathname, reload } = useRouter(); const pathWithoutLocale = useMemo( () => getPathWithoutLocale(pathname), [pathname] ); const redirectionFunction = useCallback( (locale: LocalesValues) => { const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale); push(pathWithLocale); return reload(); }, [pathWithoutLocale] ); const reactLocaleHook = useLocaleReact({ onLocaleChange: redirectionFunction, }); return { ...reactLocaleHook, pathWithoutLocale, }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server