Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.

Commit 7d60060

Browse files
committed
feat(components): 🌐 add i18n in TheHeader
1 parent 2473dc9 commit 7d60060

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

components/the/TheHeader.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@
99
>
1010
</NuxtLink>
1111
<nav id="nav">
12-
<NuxtLink class="nav-item" to="/">Home</NuxtLink>
13-
<NuxtLink class="nav-item" to="/plugins">Plugins</NuxtLink>
12+
<NuxtLink class="nav-item" to="/">{{ t("home") }}</NuxtLink>
13+
<NuxtLink class="nav-item" to="/plugins">{{ t("plugins") }}</NuxtLink>
1414
</nav>
15+
<ElSelect
16+
v-model="localeRef"
17+
@change="val => $i18n.setLocale(val)"
18+
>
19+
<el-option
20+
v-for="item in $i18n.locales"
21+
:key="item.name"
22+
:value="item.code"
23+
:label="item.name"
24+
/>
25+
</ElSelect>
1526
</div>
1627
</header>
1728
</template>
1829

1930
<script setup lang="ts">
31+
const {locale, t} = useI18n();
32+
const localeRef = ref(locale.value);
2033
</script>
2134

2235
<style lang="scss" scoped>
@@ -59,3 +72,13 @@
5972
}
6073
}
6174
</style>
75+
76+
<i18n locale="en-US" lang="yaml">
77+
home: Home
78+
plugins: Plugins
79+
</i18n>
80+
81+
<i18n locale="zh-CN" lang="yaml">
82+
home: 主页
83+
plugins: 插件
84+
</i18n>

0 commit comments

Comments
 (0)