summaryrefslogtreecommitdiff
path: root/docs/src/pages/index.astro
blob: 203ed38cfc95b86cf51761feab888313fb23f69b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
import Layout from '../layouts/MainLayout.astro';
---

<meta http-equiv="refresh" content="5;url=/en/getting-started">
<script>
	// WIP: trigger a client-side redirect based on the browser language.
	// 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.
	const KNOWN_LANGUAGES = [
		'bg',
		'de',
		'en',
		'es',
		'fi',
		'nl',
		'pt-br',
		'zh-CN',
		'zh-TW',
		'fr',
		'kr',
		'da',
		'ja',
	];
	let newLangWithRegion = (
		window.navigator.userLanguage ||
		window.navigator.language ||
		'en-US'
	).substr(0, 5);
	let newLang = newLangWithRegion.substr(0, 2);
	if (KNOWN_LANGUAGES.includes(newLangWithRegion)) {
		window.location.pathname = '/' + newLangWithRegion + '/getting-started';
	} else if (KNOWN_LANGUAGES.includes(newLang)) {
		window.location.pathname = '/' + newLang + '/getting-started';
	} else {
		window.location.pathname = '/en/getting-started';
	}
</script>