Introduce multi-lingual docs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-20 18:44:13 +02:00
parent ef29894227
commit f3566430a3
7 changed files with 86 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
const languages = ["fr"];
const navigatorLanguage =
window.navigator.userLanguage || window.navigator.language;
let language;
if (languages.includes(navigatorLanguage)) {
language = navigatorLanguage;
}
const split = navigatorLanguage.split("-")[0];
if (languages.includes(split)) {
language = split;
}
const url = new URL(window.location.href);
if (language && (url.pathname === "/" || url.pathname.startsWith("/use/"))) {
url.pathname = `/${language}${url.pathname}`;
window.location.replace(url);
}