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

@@ -1,18 +1,18 @@
<template>
<view class="booking-detail-page tn-safe-area-inset-bottom">
<tn-nav-bar :isBack="true" :bottomShadow="false" backgroundColor="#FFFFFF">
<view class="tn-text-bold tn-text-xl tn-color-black">{{ t('navTitle') }}</view>
<view class="tn-text-bold tn-text-xl tn-color-black">{{ $tr('预订详情') }}</view>
</tn-nav-bar>
<view class="page-content tn-padding" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
<view v-if="loading" class="empty-card tn-padding-lg">
<view class="booking-title">{{ t('loadingTitle') }}</view>
<view class="demo-desc tn-margin-top-sm">{{ t('loadingDesc') }}</view>
<view class="booking-title">{{ $tr('订单加载中') }}</view>
<view class="demo-desc tn-margin-top-sm">{{ $tr('正在同步该预订的真实详情,请稍候。') }}</view>
</view>
<view v-else-if="booking" class="booking-card tn-padding-lg">
<view class="tn-flex tn-flex-row-between tn-flex-col-center">
<view>
<view class="booking-title">{{ t('orderNoLabel') }}</view>
<view class="booking-title">{{ $tr('预定单号') }}</view>
<view class="booking-order tn-margin-top-xs">{{ booking.orderNo }}</view>
</view>
<view class="status-badge" :class="'status-' + booking.tagType">{{ booking.statusText }}</view>
@@ -20,48 +20,48 @@
<view class="info-box tn-margin-top">
<view class="info-row tn-flex tn-flex-row-between tn-margin-bottom-sm">
<text class="info-label">{{ t('roomTypeLabel') }}</text>
<text class="info-label">{{ $tr('风格房型') }}</text>
<text class="info-value">{{ booking.roomTypeText }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between tn-margin-bottom-sm">
<text class="info-label">{{ t('buildingFloorLabel') }}</text>
<text class="info-label">{{ $tr('楼栋楼层') }}</text>
<text class="info-value">{{ booking.buildingFloorText }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between tn-margin-bottom-sm">
<text class="info-label">{{ t('roomNoLabel') }}</text>
<text class="info-label">{{ $tr('房间号') }}</text>
<text class="info-value">{{ booking.roomNoText }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between tn-margin-bottom-sm">
<text class="info-label">{{ t('areaLabel') }}</text>
<text class="info-label">{{ $tr('所属区域') }}</text>
<text class="info-value">{{ booking.areaText }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between tn-margin-bottom-sm">
<text class="info-label">{{ t('stayDateLabel') }}</text>
<text class="info-value">{{ booking.startDateText }}{{ t('dateRangeJoiner') }}{{ booking.endDateText }}</text>
<text class="info-label">{{ $tr('入住时间') }}</text>
<text class="info-value">{{ booking.startDateText }}{{ $tr(' 至 ') }}{{ booking.endDateText }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('submittedAtLabel') }}</text>
<text class="info-label">{{ $tr('提交时间') }}</text>
<text class="info-value">{{ booking.createdAtText }}</text>
</view>
</view>
<view v-if="booking.rejectReasonText" class="reason-box tn-margin-top">
<view class="reason-title">{{ t('rejectReasonTitle') }}</view>
<view class="reason-title">{{ $tr('驳回原因') }}</view>
<view class="reason-content tn-margin-top-xs">{{ booking.rejectReasonText }}</view>
</view>
<view class="flow-box tn-margin-top">
<view class="flow-title">{{ t('flowTitle') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('pending_review') ? 'active' : ''">{{ t('flowStep1') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('approved_wait_assign') ? 'active' : ''">{{ t('flowStep2') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('assigned_wait_room') ? 'active' : ''">{{ t('flowStep3') }}</view>
<view class="flow-title">{{ $tr('当前流程') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('pending_review') ? 'active' : ''">{{ $tr('1. 已支付,等待角色审批') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('approved_wait_assign') ? 'active' : ''">{{ $tr('2. 审批通过,等待分配管家') }}</view>
<view class="flow-step tn-margin-top-sm" :class="isStepActive('assigned_wait_room') ? 'active' : ''">{{ $tr('3. 已分配管家,等待分配房号') }}</view>
</view>
</view>
<view v-else class="empty-card tn-padding-lg">
<view class="booking-title">{{ t('emptyTitle') }}</view>
<view class="demo-desc tn-margin-top-sm">{{ t('emptyDesc') }}</view>
<view class="booking-title">{{ $tr('暂无预订记录') }}</view>
<view class="demo-desc tn-margin-top-sm">{{ $tr('当前暂无可查看的预订详情,请先前往预订记录确认订单。') }}</view>
</view>
</view>
</view>
@@ -78,52 +78,6 @@ import {
} from '../../utils/booking-helper'
export default {
i18n: {
zh: {
navTitle: '预订详情',
loadingTitle: '订单加载中',
loadingDesc: '正在同步该预订的真实详情,请稍候。',
orderNoLabel: '预定单号',
roomTypeLabel: '风格房型',
buildingFloorLabel: '楼栋楼层',
roomNoLabel: '房间号',
areaLabel: '所属区域',
stayDateLabel: '入住时间',
submittedAtLabel: '提交时间',
rejectReasonTitle: '驳回原因',
flowTitle: '当前流程',
flowStep1: '1. 已支付,等待角色审批',
flowStep2: '2. 审批通过,等待分配管家',
flowStep3: '3. 已分配管家,等待分配房号',
emptyTitle: '暂无预订记录',
emptyDesc: '当前暂无可查看的预订详情,请先前往预订记录确认订单。',
cachedDetailShown: '网络异常,已展示最近同步详情',
loadFailed: '预订详情加载失败',
dateRangeJoiner: ' 至 '
},
en: {
navTitle: 'Booking Detail',
loadingTitle: 'Loading booking',
loadingDesc: 'Syncing the latest booking details. Please wait.',
orderNoLabel: 'Booking No.',
roomTypeLabel: 'Room Type',
buildingFloorLabel: 'Building / Floor',
roomNoLabel: 'Room No.',
areaLabel: 'Area',
stayDateLabel: 'Stay Dates',
submittedAtLabel: 'Submitted At',
rejectReasonTitle: 'Rejection Reason',
flowTitle: 'Current Flow',
flowStep1: '1. Paid and waiting for approval',
flowStep2: '2. Approved and waiting for butler assignment',
flowStep3: '3. Butler assigned and waiting for room allocation',
emptyTitle: 'No booking record',
emptyDesc: 'No booking detail is available right now. Please check your booking records first.',
cachedDetailShown: 'Network issue detected. Showing the latest synced detail.',
loadFailed: 'Failed to load booking detail',
dateRangeJoiner: ' to '
}
},
data() {
return {
orderNo: '',
@@ -148,9 +102,6 @@ export default {
await this.refreshBooking()
},
methods: {
t(key, params) {
return this.$tm('pkgBooking.booking_detail.booking_detail', key, params)
},
getStoreUser() {
return (this.$store && this.$store.state && this.$store.state.vuex_user) || {}
},
@@ -205,8 +156,8 @@ export default {
this.booking = this.resolveBookingFromList(normalizeBookingList(cachedList, this.language))
uni.showToast({
title: this.booking
? this.t('cachedDetailShown')
: ((error && (error.message || error.msg)) || this.t('loadFailed')),
? this.$tr('网络异常,已展示最近同步详情')
: ((error && (error.message || error.msg)) || this.$tr('预订详情加载失败')),
icon: 'none'
})
})