refactor: 国际化文本迁移至全局 locales/messages.js

将组件级 i18n 对象重构为统一由全局 locales/messages.js 管理,确保中英文语言切换时正确显示对应文本。

- 新增 utils/i18n.js 国际化工具函数
- 更新 store/$t.mixin.js 翻译混入逻辑
- 迁移 pkgService、pkgBooking、pkgAccount、pkgExplore、pages 等共 58 个组件的中英文文本至全局消息表
This commit is contained in:
liangjian
2026-07-24 13:43:41 +08:00
parent 445bd850f4
commit 6e721ccc7e
58 changed files with 1810 additions and 4065 deletions

View File

@@ -7,31 +7,31 @@
<text class='icon tn-icon-left'></text>
</view>
<view class="tn-flex tn-flex-col-center tn-flex-row-center ">
<text class="tn-text-bold tn-text-xl tn-color-black">{{ t('navTitle') }}</text>
<text class="tn-text-bold tn-text-xl tn-color-black">{{ $tr('应用专区') }}</text>
</view>
</tn-nav-bar>
<view class="top-fixed" :style="{paddingTop: vuex_custom_bar_height + 10 + 'px'}">
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-padding-left-sm tn-padding-right-sm">
<view class="tn-flex tn-flex-col-center tn-padding-sm">
<view class="tn-padding-right-xs">{{ t('sortDefault') }}</view>
<view class="tn-padding-right-xs">{{ $tr('默认') }}</view>
<!-- <view class="ri-bookmark-line tn-color-gray--dark"></view> -->
</view>
<view class="tn-flex tn-flex-col-center tn-padding-sm" @tap="openTypeModal">
<view class="tn-padding-right-xs">{{ t('typeLabel') }}</view>
<view class="tn-padding-right-xs">{{ $tr('类型') }}</view>
<view class="tn-icon-down-fill icon-active" v-if="showTypeModal"></view>
<view class="tn-icon-down-fill tn-color-gray--dark" v-else></view>
</view>
<view class="tn-flex tn-flex-col-center tn-padding-sm">
<view class="tn-padding-right-xs">{{ t('salesLabel') }}</view>
<view class="tn-padding-right-xs">{{ $tr('销量') }}</view>
<view class="tn-icon-sort tn-color-gray--dark"></view>
</view>
<view class="tn-flex tn-flex-col-center tn-padding-sm">
<view class="tn-padding-right-xs">{{ t('priceLabel') }}</view>
<view class="tn-padding-right-xs">{{ $tr('价格') }}</view>
<view class="tn-icon-sort tn-color-gray--dark"></view>
</view>
<view class="tn-flex tn-flex-col-center tn-padding-sm" @tap="openSelectModal">
<view class="tn-padding-right-xs">{{ t('comprehensiveLabel') }}</view>
<view class="tn-padding-right-xs">{{ $tr('综合') }}</view>
<view class="tn-icon-filter tn-color-gray--dark tn-text-sm"></view>
</view>
</view>
@@ -58,7 +58,7 @@
<view class="justify-content-item tn-flex tn-flex-col-center tn-padding-left-sm tn-padding-right-sm" style="margin-left: -6rpx;color: #333333;">
<text class="tn-text-sm">¥</text>
<text class="tn-padding-right-sm tn-text-lg tn-text-bold">{{ item.price }}</text>
<text class="tn-color-gray tn-text-sm" style="color: #C1CACF;"> {{ item.number }} {{ t('purchasedSuffix') }}</text>
<text class="tn-color-gray tn-text-sm" style="color: #C1CACF;"> {{ item.number }} {{ $tr('人已购') }}</text>
</view>
<!-- <view class="justify-content-item tn-flex tn-flex-col-center">
<tn-button size="sm" shape="icon" backgroundColor="#3e486400" fontColor="#333333" padding="10rpx 0 0 0">
@@ -95,40 +95,6 @@
components: { TypeModal , SelectModal },
name: 'TemplateFilter',
mixins: [template_page_mixin],
i18n: {
zh: {
navTitle: '应用专区',
sortDefault: '默认',
typeLabel: '类型',
salesLabel: '销量',
priceLabel: '价格',
comprehensiveLabel: '综合',
purchasedSuffix: '人已购',
product1: '蛋仔派对',
product2: '保卫萝卜',
product3: '旅行青蛙',
product4: '辐射避难所',
product5: '王国保卫战',
product6: '崩坏 · 星穹铁道',
product7: '纪念碑谷'
},
en: {
navTitle: 'App Zone',
sortDefault: 'Default',
typeLabel: 'Type',
salesLabel: 'Sales',
priceLabel: 'Price',
comprehensiveLabel: 'All',
purchasedSuffix: 'purchased',
product1: 'Eggy Party',
product2: 'Carrot Defense',
product3: 'Travel Frog',
product4: 'Fallout Shelter',
product5: 'Kingdom Rush',
product6: 'Honkai: Star Rail',
product7: 'Monument Valley'
}
},
data(){
return {
/* 选择弹窗*/
@@ -197,14 +163,11 @@
}
},
methods: {
t(key, params) {
return this.$tm('pkgExplore.filter.filter', key, params)
},
syncProducts() {
const keys = ['product1', 'product2', 'product3', 'product4', 'product5', 'product6', 'product7']
const names = ['蛋仔派对', '保卫萝卜', '旅行青蛙', '辐射避难所', '王国保卫战', '崩坏 · 星穹铁道', '纪念碑谷']
this.product = this.product.map((item, index) => ({
...item,
desc: this.t(keys[index] || 'product1')
desc: this.$tr(names[index] || '蛋仔派对')
}))
},
// 打开选择弹框