Is your feature request related to a problem? Please describe.
In some cases, I need to know the current locale value as a string. For example, I may need to pass it to a redirect({href: '...', locale: '...'}). It will be the best if this can be exported, and be callable from the library.
and pass that params.locale all the way down to components/actions, but that introduces a nasty call chain.
I can do a usePathname() using "next/navigation" and another usePathname() using "@/i18n/routing" and subtract between the two. But that really feels like a hack.
Is your feature request related to a problem? Please describe.
In some cases, I need to know the current
locale
value as a string. For example, I may need to pass it to aredirect({href: '...', locale: '...'})
. It will be the best if this can be exported, and be callable from the library.Describe the solution you'd like
I think export the
useLocale()
function https://github.com/amannn/next-intl/blob/5d60cdf3d0806a900216c76768111d172065ae72/packages/next-intl/src/react-client/useLocale.tsx#L6 or https://github.com/amannn/next-intl/blob/5d60cdf3d0806a900216c76768111d172065ae72/packages/next-intl/src/server/react-server/getRequestConfig.tsx#L14 for external use will work.Describe alternatives you've considered
I can potentially:
and pass that
params.locale
all the way down to components/actions, but that introduces a nasty call chain.usePathname()
using"next/navigation"
and anotherusePathname()
using"@/i18n/routing"
and subtract between the two. But that really feels like a hack.