theowenyoung / gatsby-plugin-intl

Gatsby plugin that turns your website into an internationalization-framework out of the box.

Home Page:https://gatsby-plugin-react-intl.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Detect language from URL

davide-cattani opened this issue · comments

Hello, i'm experimenting with your plugin and i have a request, if possible.

Is there a way to get the current locale in the URL?
For example:
I'm visiting the webite from Italy, so this

const intl = useIntl()
const lang = intl.locale

results in lang to be equal to it.

If i then navigate to /en/index, the lang variable remains equal to it.

What will be useful to me is a different variable (urlLocale ?) telling me the locale as per the URL, even if it is different from the user browser locale.

This way i can show english pages if the user "switches" language from the URL.

Hello @davide-cattani, is there any updates from this ?

Hello @davide-cattani, is there any updates from this ?

I wish! I had no luck so i had to move to a whole another stack