i18n test. The default i18n approach in VitePress (https://vitepress.dev/guide/i18n) doesn't make much sense - having separate folder structures for each language. Well, it technically makes sense, but the energy investment isn't appealing. It might be better to detect browser fingerprint and show content based on nationality..
{
"title": "default-i18n-makes-no-sense",
"description": "",
"frontmatter": {
"title": "default-i18n-makes-no-sense",
"hello": "world"
},
"headers": [],
"relativePath": "blog/2025/15jan2025.md",
"filePath": "blog/2025/15jan2025.md",
"lastUpdated": 1771222978000
}vue
<script setup>
import { ref, onMounted } from 'vue'
import { useData } from 'vitepress'
const browserName = ref('')
const browserVersion = ref('')
const platform = ref('')
const language = ref('')
const cookiesEnabled = ref('')
onMounted(() => {
if (navigator.userAgentData) {
browserName.value = navigator.userAgentData.brands.map(brand => brand.brand).join(', ')
browserVersion.value = navigator.userAgentData.brands.map(brand => brand.version).join(', ')
} else {
const ua = navigator.userAgent
let match = ua.match(/(opera|chrome|safari|firefox|edge|trident(?=\/))\/?\s*(\d+)/i) || []
if (/trident/i.test(match[1])) {
const rv = ua.match(/\brv[ :]+(\d+)/g) || []
browserName.value = 'IE'
browserVersion.value = rv[0].replace(/[^\d]/g, '')
}
if (match[1] === 'Chrome') {
const tem = ua.match(/\b(OPR|Edg)\/(\d+)/)
if (tem != null) {
browserName.value = tem.slice(1).join(' ').replace('OPR', 'Opera').replace('Edg', 'Edge')
browserVersion.value = tem[2]
}
}
match = match[2] ? [match[1], match[2]] : [navigator.appName, navigator.appVersion, '-?']
const tem = ua.match(/version\/(\d+)/i)
if (tem != null) {
match.splice(1, 1, tem[1])
}
browserName.value = match[0]
browserVersion.value = match[1]
}
platform.value = navigator.platform || 'no idea'
language.value = navigator.language || 'no idea'
cookiesEnabled.value = navigator.cookieEnabled ? 'si' : 'no'
})
</script>I track your browser information, and you enjoy automated language selection.. so evil..
> (Demo) Below shows the actual language-branched result. If you set it to en-US you'll see English, if ko-KR you'll see Korean
english
## Browser Information
- Browser Name:
- Browser Version:
- Platform:
- Language:
- Cookies Enabled: