cagov / covid19

This is the official COVID19 response website for the state of California.
https://covid19.ca.gov/
44 stars 22 forks source link

Language Detection #1323

Open carterm opened 4 years ago

carterm commented 4 years ago

We can use local storage and an API service to detect the language the user prefers and send them there automatically the first time they hit the site.

Once a language preset has been made, the user will no longer be auto-redirected.

Option: We could store the language they were using in local storage and return them there when they hit the homepage.

We should create a reusable api for this, that will use the browsers built in "accept-language:" header to determine the users preferred language, while receiving a list of the site's supported languages. The service can return the suggested language.

xjensen commented 4 years ago

For what it's worth, I've had good luck in the past using CDNs to do some of this work. Many CDNs have powerful routing features that could be used to evaluate cookie and/or accept-language headers, then redirect/deliver preferred content. For example, Azure CDN offers the Rules Engine which could probably do this.

Not sure if the site is served via CDN or if there are other constraints here. Just wanted to pitch this idea.