Topics

Automatic locale selection (will change URLs by adding /en/ to English URLs)


David A. Wheeler
 

We now have complete localizations for French, (Simplified) Chinese, and Japanese. German and Russian are past the halfway mark as well. My sincere thanks to all the translators!!

It now makes sense to *automatically* redirect people to their preferred locales. Unfortunately, there's currently no way to distinguish between "users who want English" and "users who want their preferred locale".

As a result, we need to make *some* change to our URLs so that automatic locale selection can work. The current plan is that if you provide a URL *without* a specific locale identified, you'll be redirected to a URL with a locale (it'll be whatever your browser most prefers that we support, and English if none are supported). As a result, if you visit:
https://bestpractices.coreinfrastructure.org/projects/1
and the best fit is English (en), you'll be redirected to:
https://bestpractices.coreinfrastructure.org/en/projects/1

Similarly, a visit to the home page:
https://bestpractices.coreinfrastructure.org/
Will redirect you. If the best fit is English (en), you'll be redirected to:
https://bestpractices.coreinfrastructure.org/en
but you prefer simplified Chinese, you'll instead be redirected to:
https://bestpractices.coreinfrastructure.org/zh-CN

This should work out well. People can, at any time, select their preferred locale on the website (as they do now) and it will continue to work. There seems to be a general consensus that the actual locale should be part of the URL, and *not* be stored in a session or cookie, so that a particular URL will lead to the same material. This also avoids locale selection by geolocation, which is widely considered a bad idea (not everyone in a region shares the same locale preference - at the very least, when you're on travel *you* should be able to choose). More discussion about this approach is here:
https://github.com/coreinfrastructure/best-practices-badge/pull/805

One exception: the plan is that the badge images (e.g., /projects/1/badge) will *not* have a locale prefix. They're constant regardless of locale, and making them locale-less means that they'll cache better (through better sharing).

--- David A. Wheeler