feat(i18n): 集成 vue-i18n 并配置多语言支持
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 4m24s
CI/CD Pipeline / build-and-deploy (push) Successful in 5m33s

(cherry picked from commit 15c9509318dd7d48c081c4ae4846598d9affb344)
This commit is contained in:
严浩
2025-10-22 18:31:44 +08:00
parent 917301dea6
commit 0ac7636c74
9 changed files with 184 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
<script setup lang="ts">
definePage({
meta: {
title: '国际化示例',
},
});
const { t, locale } = useI18n();
function setLocale(newLocale: 'en-US' | 'zh-CN') {
locale.value = newLocale;
}
</script>
<template>
<div class="p-4">
<n-h1>{{ t('page.i18n-demo.title') }}</n-h1>
<n-card :title="t('page.i18n-demo.change-language')">
<n-p>
{{ t('page.i18n-demo.current-language') }}:
<span class="font-bold">{{ locale }}</span>
</n-p>
<n-p>
{{ t('page.i18n-demo.hello', { name: 'Kilo' }) }}
</n-p>
<n-space>
<n-button type="primary" @click="setLocale('en-US')"> English </n-button>
<n-button type="success" @click="setLocale('zh-CN')"> 简体中文 </n-button>
</n-space>
</n-card>
</div>
</template>