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 App from "./App.vue";
|
||||||
import pinia from "@/stores";
|
import pinia from "@/stores";
|
||||||
import * as Pinia from 'pinia';
|
import * as Pinia from 'pinia';
|
||||||
|
import i18n from "@/locales";
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App);
|
const app = createSSRApp(App);
|
||||||
|
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
|
app.use(i18n)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<image class="logo" src="/static/logo.png" />
|
<image class="logo" src="/static/logo.png"/>
|
||||||
<view class="text-area">
|
<view class="text-area">
|
||||||
<text class="title">{{ title }}</text>
|
<text class="title">{{ title }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -8,8 +8,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
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>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue