This commit is contained in:
zhang zhuo 2025-06-18 18:11:50 +08:00
parent 93d70995d6
commit 81124a6329
5 changed files with 38 additions and 3 deletions

17
src/locales/index.ts Normal file
View File

@ -0,0 +1,17 @@
import {createI18n} from 'vue-i18n'
import en from './lang/en'
import zhHans from './lang/zh-cn'
const messages = {
en,
'zh-Hans': zhHans
}
const i18n = createI18n({
locale: uni.getLocale(),
messages,
legacy: false
})
export default i18n;

5
src/locales/lang/en.ts Normal file
View File

@ -0,0 +1,5 @@
export default {
system: {
title: 'hello',
},
}

View File

@ -0,0 +1,5 @@
export default {
system: {
title: '你好',
},
}

View File

@ -2,11 +2,13 @@ import { createSSRApp } from "vue";
import App from "./App.vue";
import pinia from "@/stores";
import * as Pinia from 'pinia';
import i18n from "@/locales";
export function createApp() {
const app = createSSRApp(App);
app.use(pinia)
app.use(i18n)
return {
app,

View File

@ -9,7 +9,13 @@
<script setup lang="ts">
import {ref} from 'vue'
const title = ref('Hello')
import {useI18n} from 'vue-i18n'
const {t, locale} = useI18n()
const title = ref(t('system.title'))
console.log(title)
</script>
<style>