0

I'm building a blog with Gatsby with support for 2 languages.

Most of the concerns about the internationalization of the web are done, but I don't how I could redirect to the visitors based on their language. For example, if a Spanish person visits the index of my pages, I would like to redirect them to /es/index route.

Ryszard Czech
  • 18,032
  • 4
  • 24
  • 37
Ismael Rodriguez
  • 329
  • 3
  • 10
  • I hope this Blog can help you `https://www.techrepublic.com/article/detect-foreign-language-support-using-javascript/` – Sohan May 17 '20 at 19:05
  • Does this answer your question? [JavaScript for detecting browser language preference](https://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference) – ichigolas May 17 '20 at 21:51

1 Answers1

0

You can use vanilla javascript to get the user language from the browser

window.navigator.language

then redirect based on the language gotten.

Rocard Fonji
  • 375
  • 3
  • 12