i18n
This commit is contained in:
parent
93d70995d6
commit
81124a6329
|
|
@ -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;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export default {
|
||||
system: {
|
||||
title: 'hello',
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export default {
|
||||
system: {
|
||||
title: '你好',
|
||||
},
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view class="content">
|
||||
<image class="logo" src="/static/logo.png" />
|
||||
<image class="logo" src="/static/logo.png"/>
|
||||
<view class="text-area">
|
||||
<text class="title">{{ title }}</text>
|
||||
</view>
|
||||
|
|
@ -8,8 +8,14 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
const title = ref('Hello')
|
||||
import {ref} from 'vue'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
|
||||
const {t, locale} = useI18n()
|
||||
const title = ref(t('system.title'))
|
||||
|
||||
console.log(title)
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue