Skip to content

Commit 4939d57

Browse files
committed
chore: add i18n
1 parent cd40030 commit 4939d57

File tree

8 files changed

+778
-15
lines changed

8 files changed

+778
-15
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,9 @@
8383
"scss",
8484
"pcss",
8585
"postcss"
86+
],
87+
"i18n-ally.localesPaths": [
88+
"i18n",
89+
"i18n/locales"
8690
]
8791
}

app/pages/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const runtimeConfig = useRuntimeConfig()
33
const colors = ['#f87171', '#fb923c', '#fbbf24', '#facc15', '#a3e635', '#4ade80', '#34d399', '#2dd4bf', '#22d3ee', '#38bdf8', '#60a5fa', '#818cf8', '#a78bfa', '#c084fc', '#e879f9', '#f472b6', '#fb7185']
44
const color = useState('color', () => colors[Math.floor(Math.random() * colors.length)])
5+
const { t } = useI18n()
56
</script>
67

78
<template>
@@ -10,7 +11,7 @@ const color = useState('color', () => colors[Math.floor(Math.random() * colors.l
1011
{{ runtimeConfig.public.helloText }}
1112
</h1>
1213
<NuxtLink to="/" external>
13-
refresh
14+
{{ t('Refresh') }}
1415
</NuxtLink>
1516
</div>
1617
</template>

i18n/locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Refresh": "Aktualisieren"
3+
}

i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Refresh": "Refresh"
3+
}

i18n/locales/es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Refresh": "Refrescar"
3+
}

nuxt.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default defineNuxtConfig({
55
'@nuxthub/core',
66
'@nuxt/eslint',
77
'@unocss/nuxt',
8+
'@nuxtjs/i18n',
89
],
910

1011
// https://devtools.nuxt.com
@@ -30,4 +31,26 @@ export default defineNuxtConfig({
3031
standalone: false,
3132
},
3233
},
34+
35+
// https://i18n.nuxtjs.org
36+
i18n: {
37+
locales: [
38+
{
39+
code: 'en',
40+
iso: 'en-US',
41+
file: 'en.json',
42+
},
43+
{
44+
code: 'de',
45+
iso: 'de-DE',
46+
file: 'de.json',
47+
},
48+
{
49+
code: 'es',
50+
iso: 'es-ES',
51+
file: 'es.json',
52+
},
53+
],
54+
defaultLocale: 'en',
55+
},
3356
})

0 commit comments

Comments
 (0)