简体   繁体   中英

Made a redirection depending on the language of the visitor

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.

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

window.navigator.language

then redirect based on the language gotten.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM