2021-07-15 14:13:35 -04:00
|
|
|
---
|
2021-07-30 22:39:15 -07:00
|
|
|
import Layout from '../layouts/MainLayout.astro';
|
2021-07-15 14:13:35 -04:00
|
|
|
---
|
|
|
|
|
2021-07-30 22:39:15 -07:00
|
|
|
<script>
|
2021-08-13 11:49:41 -05:00
|
|
|
// WIP: trigger a client-side redirect based on the browser language.
|
2021-08-05 00:05:00 +08:00
|
|
|
// A vercel.json redirect is enforced in production, so no user should ever see this page.
|
|
|
|
// Remove the vercel.json redirect when this is ready.
|
2021-08-27 22:01:06 +02:00
|
|
|
const KNOWN_LANGUAGES = ['bg', 'de','en','es','fi','nl','pt-br','zh-CN','zh-TW', 'fr', 'kr', 'da'];
|
2021-08-04 14:22:11 -07:00
|
|
|
let newLangWithRegion = (window.navigator.userLanguage || window.navigator.language || 'en-US').substr(0, 5);
|
|
|
|
let newLang = newLangWithRegion.substr(0, 2);
|
2021-07-30 22:39:15 -07:00
|
|
|
if (newLang === 'en') {
|
|
|
|
window.location.pathname = '/getting-started';
|
2021-08-04 14:22:11 -07:00
|
|
|
} else if (KNOWN_LANGUAGES.includes(newLangWithRegion)) {
|
|
|
|
window.location.pathname = '/' + newLangWithRegion + '/getting-started';
|
2021-07-30 22:39:15 -07:00
|
|
|
} else if (KNOWN_LANGUAGES.includes(newLang)) {
|
|
|
|
window.location.pathname = '/' + newLang + '/getting-started';
|
|
|
|
} else {
|
2021-08-04 14:22:11 -07:00
|
|
|
window.location.pathname = '/getting-started';
|
2021-07-30 22:39:15 -07:00
|
|
|
}
|
2021-08-06 08:51:07 +03:00
|
|
|
</script>
|