feat: 把i18n的东西放到 i18n.vue
This commit is contained in:
parent
7e2cda4886
commit
960580fd62
@ -29,6 +29,10 @@ const i18n = createI18n({
|
|||||||
* @param { string } localeKey 多语言的key,eg: "app.name"
|
* @param { string } localeKey 多语言的key,eg: "app.name"
|
||||||
*/
|
*/
|
||||||
export const translate = (localeKey: string) => {
|
export const translate = (localeKey: string) => {
|
||||||
|
if (!localeKey) {
|
||||||
|
console.error(`[i18n] Function translate(), localeKey param is required`)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
const locale = getLocale()
|
const locale = getLocale()
|
||||||
const message = messages[locale]
|
const message = messages[locale]
|
||||||
if (Object.keys(message).includes(localeKey)) {
|
if (Object.keys(message).includes(localeKey)) {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
<template>{{ $t('app.name') }}</template>
|
|
||||||
|
|
||||||
<route lang="json">
|
<route lang="json">
|
||||||
{
|
{
|
||||||
"style": {
|
"style": {
|
||||||
@ -7,3 +5,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<template>{{ $t('app.name') }}</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { testI18n } from '@/utils/index'
|
||||||
|
|
||||||
|
testI18n()
|
||||||
|
</script>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<route lang="json5" type="home">
|
<route lang="json5" type="home">
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
// "navigationStyle": "custom",
|
navigationStyle: 'custom',
|
||||||
navigationBarTitleText: '%app.name%',
|
navigationBarTitleText: '首页',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
@ -12,7 +12,6 @@
|
|||||||
class="bg-white h-full overflow-hidden pt-2 px-4"
|
class="bg-white h-full overflow-hidden pt-2 px-4"
|
||||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
||||||
>
|
>
|
||||||
<view>{{ $t('app.name') }}</view>
|
|
||||||
<view class="mt-12">
|
<view class="mt-12">
|
||||||
<image src="/static/logo.svg" alt="" class="w-40 h-40 block mx-auto" />
|
<image src="/static/logo.svg" alt="" class="w-40 h-40 block mx-auto" />
|
||||||
</view>
|
</view>
|
||||||
@ -38,15 +37,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { testI18n } from '@/utils/index'
|
|
||||||
|
|
||||||
testI18n()
|
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// 获取屏幕边界到安全区域距离
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
|
|
||||||
const author = ref('菲鸽')
|
|
||||||
console.log(author)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user