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

@@ -12,22 +12,22 @@
<view class="tn-bg-gray--light tn-padding-xl tn-border-radius-circle tn-margin-bottom">
<text class="tn-icon-lock tn-color-gray" style="font-size: 80rpx;"></text>
</view>
<view class="hero-title tn-text-bold">{{ t('lockNoAccessTitle') }}</view>
<view class="hero-desc tn-margin-top-sm tn-text-center">{{ t('lockNoAccessDesc') }}</view>
<view class="hero-title tn-text-bold">{{ $tr('暂无门锁权限') }}</view>
<view class="hero-desc tn-margin-top-sm tn-text-center">{{ $tr('您当前暂未分配智能门锁,或门锁暂未联网。\n入住后即可使用一键开门与临时密码下发功能。') }}</view>
<view class="tn-flex tn-margin-top-xl tn-width-full tn-flex-row-between">
<view class="btn-light tn-flex-1 tn-margin-right-sm tn-flex tn-flex-col-center tn-flex-row-center tn-padding-sm" style="border-radius: 12rpx; opacity: 0.6;">
<text class="tn-icon-key tn-margin-right-xs"></text> {{ t('tempPassword') }}
<text class="tn-icon-key tn-margin-right-xs"></text> {{ $tr('临时密码') }}
</view>
<view class="btn-primary tn-flex-1 tn-margin-left-sm tn-flex tn-flex-col-center tn-flex-row-center tn-padding-sm" style="border-radius: 12rpx; opacity: 0.6;">
<text class="tn-icon-unlock tn-margin-right-xs"></text> {{ t('oneTapUnlock') }}
<text class="tn-icon-unlock tn-margin-right-xs"></text> {{ $tr('一键开锁') }}
</view>
</view>
</view>
<view class="record-card tn-margin-top-lg">
<view class="block-title">{{ t('authRecordTitle') }}</view>
<view class="block-title">{{ $tr('授权记录') }}</view>
<view class="tn-margin-top tn-flex tn-flex-row-center tn-padding-xl">
<tn-empty icon="tn-icon-empty-data" :text="t('lockEmptyRecord')"></tn-empty>
<tn-empty icon="tn-icon-empty-data" :text="$tr('暂无门锁操作记录')"></tn-empty>
</view>
</view>
</view>
@@ -36,16 +36,16 @@
<view v-else-if="pageKey === 'points'">
<view class="hero-card" style="background: linear-gradient(135deg, #FFB703 0%, #FF8A00 100%); color: #fff; border: none;">
<view class="tn-flex tn-flex-row-between tn-flex-col-center">
<view class="tn-text-md">{{ t('pointsAvailable') }}</view>
<view class="tn-text-sm" style="background: rgba(255,255,255,0.2); padding: 4rpx 16rpx; border-radius: 100rpx;">{{ t('redeemRules') }}</view>
<view class="tn-text-md">{{ $tr('当前可用积分') }}</view>
<view class="tn-text-sm" style="background: rgba(255,255,255,0.2); padding: 4rpx 16rpx; border-radius: 100rpx;">{{ $tr('兑换规则') }}</view>
</view>
<view class="tn-margin-top-lg tn-text-bold" style="font-size: 80rpx;">--</view>
<view class="tn-margin-top tn-flex tn-flex-row-between">
<view class="tn-flex tn-flex-col-center">
<text class="tn-icon-calendar tn-margin-right-xs"></text> {{ t('dailyPoints') }}
<text class="tn-icon-calendar tn-margin-right-xs"></text> {{ $tr('每日签到领积分') }}
</view>
<view class="tn-flex tn-flex-col-center" style="opacity: 0.8;">
{{ t('goCheckIn') }} <text class="tn-icon-right tn-margin-left-xs"></text>
{{ $tr('去签到') }} <text class="tn-icon-right tn-margin-left-xs"></text>
</view>
</view>
</view>
@@ -53,20 +53,20 @@
<view class="tn-flex tn-flex-row-between tn-margin-top-lg">
<view class="btn-light tn-flex-1 tn-margin-right-sm tn-flex tn-flex-direction-column tn-flex-col-center tn-padding-lg" style="border-radius: 20rpx;">
<text class="tn-icon-shop tn-color-orange tn-margin-bottom-sm" style="font-size: 60rpx;"></text>
<text class="tn-text-bold tn-color-black">{{ t('pointsMall') }}</text>
<text class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ t('pointsMallDesc') }}</text>
<text class="tn-text-bold tn-color-black">{{ $tr('积分商城') }}</text>
<text class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ $tr('超值好物兑换') }}</text>
</view>
<view class="btn-light tn-flex-1 tn-margin-left-sm tn-flex tn-flex-direction-column tn-flex-col-center tn-padding-lg" style="border-radius: 20rpx;">
<text class="tn-icon-coupon tn-color-purplered tn-margin-bottom-sm" style="font-size: 60rpx;"></text>
<text class="tn-text-bold tn-color-black">{{ t('coupon') }}</text>
<text class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ t('couponDesc') }}</text>
<text class="tn-text-bold tn-color-black">{{ $tr('优惠券') }}</text>
<text class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ $tr('租金水电抵扣') }}</text>
</view>
</view>
<view class="record-card tn-margin-top-lg">
<view class="block-title">{{ t('pointsRecordTitle') }}</view>
<view class="block-title">{{ $tr('积分明细') }}</view>
<view class="tn-margin-top tn-flex tn-flex-row-center tn-padding-xl">
<tn-empty icon="tn-icon-empty-data" :text="t('pointsEmpty')"></tn-empty>
<tn-empty icon="tn-icon-empty-data" :text="$tr('暂无积分明细')"></tn-empty>
</view>
</view>
</view>
@@ -74,28 +74,28 @@
<!-- 一码通管理 Mockup -->
<view v-else-if="pageKey === 'code'">
<view class="hero-card tn-flex tn-flex-direction-column tn-flex-col-center">
<view class="tn-text-md tn-color-black tn-text-bold">{{ t('accessCodeTitle') }}</view>
<view class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ t('accessCodeDesc') }}</view>
<view class="tn-text-md tn-color-black tn-text-bold">{{ $tr('我的通行二维码') }}</view>
<view class="tn-text-xs tn-color-gray tn-margin-top-xs">{{ $tr('可用于社区大门、单元门及电梯通行') }}</view>
<view class="qr-code-box tn-margin-top-xl tn-margin-bottom-lg tn-flex tn-flex-col-center tn-flex-row-center">
<view class="qr-placeholder tn-flex tn-flex-col-center tn-flex-row-center">
<text class="tn-icon-qr-code tn-color-gray" style="font-size: 200rpx; opacity: 0.2;"></text>
</view>
<view class="qr-mask tn-flex tn-flex-col-center tn-flex-row-center">
<text class="tn-color-white tn-text-bold tn-text-lg">{{ t('noAccessPermission') }}</text>
<text class="tn-color-white tn-text-bold tn-text-lg">{{ $tr('未获取通行权限') }}</text>
</view>
</view>
<view class="tn-text-xs tn-color-gray tn-text-center tn-margin-bottom">{{ t('accessAssignDesc') }}</view>
<view class="tn-text-xs tn-color-gray tn-text-center tn-margin-bottom">{{ $tr('请在完成入住签约并录入人脸/实名信息后\n系统将自动为您分配通行权限') }}</view>
</view>
<view class="record-card tn-margin-top-lg">
<view class="tn-flex tn-flex-row-between tn-flex-col-center">
<view class="block-title">{{ t('visitorAccessTitle') }}</view>
<view class="tn-color-gray tn-text-sm">{{ t('visitorAccessAction') }} <text class="tn-icon-right"></text></view>
<view class="block-title">{{ $tr('访客通行') }}</view>
<view class="tn-color-gray tn-text-sm">{{ $tr('临时访客授权') }} <text class="tn-icon-right"></text></view>
</view>
<view class="tn-margin-top tn-flex tn-flex-row-center tn-padding-xl">
<tn-empty icon="tn-icon-empty-data" :text="t('visitorEmpty')"></tn-empty>
<tn-empty icon="tn-icon-empty-data" :text="$tr('暂无访客通行记录')"></tn-empty>
</view>
</view>
</view>
@@ -103,25 +103,25 @@
<!-- 默认通用占位 -->
<view v-else>
<view class="hero-card">
<view class="hero-badge">{{ t('heroBadge') }}</view>
<view class="hero-title tn-margin-top">{{ resolvedPageTitle || t('comingSoonTitle') }}</view>
<view class="hero-badge">{{ $tr('即将开放') }}</view>
<view class="hero-title tn-margin-top">{{ resolvedPageTitle || $tr('功能建设中') }}</view>
<view class="hero-desc tn-margin-top-sm">{{ resolvedPageDesc || resolvedDefaultDesc }}</view>
</view>
<view class="record-card tn-margin-top-xl">
<view class="block-title">{{ t('currentStatusTitle') }}</view>
<view class="block-title">{{ $tr('当前状态') }}</view>
<view class="empty-text tn-margin-top">
{{ t('currentStatusDesc') }}
{{ $tr('该功能当前仍在建设中,暂未开放正式办理入口。你可以先返回上一页,或回到首页继续查看已开放功能。') }}
</view>
<view class="tip-card tn-margin-top-lg">
<view class="tip-title">{{ t('noteTitle') }}</view>
<view class="tip-desc tn-margin-top-xs">{{ t('noteDesc') }}</view>
<view class="tip-title">{{ $tr('说明') }}</view>
<view class="tip-desc tn-margin-top-xs">{{ $tr('后续接入真实能力后,这里会展示正式的业务入口、状态数据和办理记录。') }}</view>
</view>
<view class="submit-btn btn-primary tn-margin-top-xl" @click="goBack">
<text class="tn-text-bold">{{ t('backPrev') }}</text>
<text class="tn-text-bold">{{ $tr('返回上一页') }}</text>
</view>
<view class="submit-btn btn-light tn-margin-top" @click="goHome">
<text class="tn-text-bold">{{ t('backHome') }}</text>
<text class="tn-text-bold">{{ $tr('返回首页') }}</text>
</view>
</view>
</view>
@@ -143,78 +143,6 @@ function safeDecodeText(value, fallback = '') {
}
export default {
i18n: {
zh: {
defaultPageTitle: '业务办理',
defaultPageDesc: '该能力正在完善中,开放后会同步到个人中心的对应入口。',
lockNoAccessTitle: '暂无门锁权限',
lockNoAccessDesc: '您当前暂未分配智能门锁,或门锁暂未联网。\n入住后即可使用一键开门与临时密码下发功能。',
tempPassword: '临时密码',
oneTapUnlock: '一键开锁',
authRecordTitle: '授权记录',
lockEmptyRecord: '暂无门锁操作记录',
pointsAvailable: '当前可用积分',
redeemRules: '兑换规则',
dailyPoints: '每日签到领积分',
goCheckIn: '去签到',
pointsMall: '积分商城',
pointsMallDesc: '超值好物兑换',
coupon: '优惠券',
couponDesc: '租金水电抵扣',
pointsRecordTitle: '积分明细',
pointsEmpty: '暂无积分明细',
accessCodeTitle: '我的通行二维码',
accessCodeDesc: '可用于社区大门、单元门及电梯通行',
noAccessPermission: '未获取通行权限',
accessAssignDesc: '请在完成入住签约并录入人脸/实名信息后\n系统将自动为您分配通行权限',
visitorAccessTitle: '访客通行',
visitorAccessAction: '临时访客授权',
visitorEmpty: '暂无访客通行记录',
heroBadge: '即将开放',
comingSoonTitle: '功能建设中',
currentStatusTitle: '当前状态',
currentStatusDesc: '该功能当前仍在建设中,暂未开放正式办理入口。你可以先返回上一页,或回到首页继续查看已开放功能。',
noteTitle: '说明',
noteDesc: '后续接入真实能力后,这里会展示正式的业务入口、状态数据和办理记录。',
backPrev: '返回上一页',
backHome: '返回首页'
},
en: {
defaultPageTitle: 'Service Center',
defaultPageDesc: 'This capability is being improved and will appear in the related personal center entry when available.',
lockNoAccessTitle: 'No door lock access',
lockNoAccessDesc: 'No smart lock is assigned yet, or the lock is currently offline.\nAfter check-in, one-tap unlock and temporary password features will be available.',
tempPassword: 'Temporary Code',
oneTapUnlock: 'Unlock Now',
authRecordTitle: 'Access Records',
lockEmptyRecord: 'No door lock records',
pointsAvailable: 'Available Points',
redeemRules: 'Redeem Rules',
dailyPoints: 'Daily check-in rewards',
goCheckIn: 'Check In',
pointsMall: 'Points Mall',
pointsMallDesc: 'Redeem for selected items',
coupon: 'Coupons',
couponDesc: 'Offset rent and utilities',
pointsRecordTitle: 'Points History',
pointsEmpty: 'No points record',
accessCodeTitle: 'My Access QR Code',
accessCodeDesc: 'Use it for community gates, unit doors, and elevators',
noAccessPermission: 'No access permission',
accessAssignDesc: 'After completing check-in signing and face / identity enrollment,\nthe system will automatically assign your access permission.',
visitorAccessTitle: 'Visitor Access',
visitorAccessAction: 'Temporary visitor authorization',
visitorEmpty: 'No visitor access records',
heroBadge: 'Coming Soon',
comingSoonTitle: 'Coming Soon',
currentStatusTitle: 'Current Status',
currentStatusDesc: 'This capability is still under development and is not yet officially available. You can go back or return to the home page to browse available features.',
noteTitle: 'Notes',
noteDesc: 'After the real capability is connected, this page will display the formal service entry, status data, and processing records.',
backPrev: 'Go Back',
backHome: 'Back Home'
}
},
data() {
return {
pageTitleZh: '',
@@ -229,9 +157,9 @@ export default {
computed: {
resolvedPageTitle() {
if (this.$getLanguage() === 'en') {
return this.pageTitleEn || this.pageTitleZh || this.rawPageTitle || this.t('defaultPageTitle')
return this.pageTitleEn || this.pageTitleZh || this.rawPageTitle || this.$tr('业务办理')
}
return this.pageTitleZh || this.pageTitleEn || this.rawPageTitle || this.t('defaultPageTitle')
return this.pageTitleZh || this.pageTitleEn || this.rawPageTitle || this.$tr('业务办理')
},
resolvedPageDesc() {
if (this.$getLanguage() === 'en') {
@@ -240,7 +168,7 @@ export default {
return this.pageDescZh || this.pageDescEn || this.rawPageDesc || ''
},
resolvedDefaultDesc() {
return this.t('defaultPageDesc')
return this.$tr('该能力正在完善中,开放后会同步到个人中心的对应入口。')
}
},
onLoad(options) {
@@ -253,9 +181,6 @@ export default {
this.pageKey = safeDecodeText(options && options.key, '')
},
methods: {
t(key, params) {
return this.$tm('pkgService.service_stub.service_stub', key, params)
},
goBack() {
uni.navigateBack()
},