Unverified Commit 3d86c6f5 authored by Sasha Sorokin's avatar Sasha Sorokin 🇷🇺

feat: add support for ?lang search parameter

This allows users to give links such as joinmastodon.org/?lang=fr to
their friends, who on visit will be seeing, in this case, French
version of the site, but users can also supply any other locale there:
if locale is not found, it will fallback to auto-detection or English.

We could have also added a copy of index.html page for every locale,
but I'm not sure how to do this, so will leave it as is.
parent 251728f7
......@@ -41,6 +41,16 @@ for (let i = 0, l = defaultLanguages.length; i < l; i++) {
}
const initialLocale = () => {
if (window.URLSearchParams) {
const params = new URLSearchParams(window.location.search);
const lang = params.get('lang');
if (supportedLocales.indexOf(lang) !== -1) {
return lang;
}
}
const lang = navigator.language.split('-')[0];
if (supportedLocales.indexOf(navigator.language) !== -1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment