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,7 +1,7 @@
<template>
<view class="auth-result-page tn-safe-area-inset-bottom">
<tn-nav-bar :isBack="true" :bottomShadow="false" backgroundColor="transparent">
<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 class="status-card fade-in">
@@ -33,7 +33,7 @@
<!-- 提交信息摘要 -->
<view v-if="profileSummary.length" class="summary-box tn-margin-top-xl tn-margin-bottom-lg tn-margin-left-lg tn-margin-right-lg">
<view class="summary-title tn-margin-bottom-sm">{{ t('submittedInfoTitle') }}</view>
<view class="summary-title tn-margin-bottom-sm">{{ $tr('已提交信息') }}</view>
<view v-for="item in profileSummary" :key="item.label" class="summary-row tn-flex tn-flex-row-between tn-padding-top-sm tn-padding-bottom-sm">
<text class="summary-label">{{ item.label }}</text>
<text class="summary-value tn-text-ellipsis">{{ item.value }}</text>
@@ -44,19 +44,19 @@
<!-- 操作按钮 -->
<view class="action-group tn-margin-top-xl fade-in-up">
<view v-if="authStatus === 'approved'" class="custom-btn btn-primary" @click="goToLogin">
<text class="tn-text-bold">{{ t('goLogin') }}</text>
<text class="tn-text-bold">{{ $tr('去登录') }}</text>
</view>
<view v-else-if="authStatus === 'rejected'" class="custom-btn btn-primary" @click="resubmit">
<text class="tn-text-bold">{{ t('resubmitRegister') }}</text>
<text class="tn-text-bold">{{ $tr('重新提交注册申请') }}</text>
</view>
<view v-else class="custom-btn btn-dark" @click="refreshStatus">
<text class="tn-text-bold tn-flex tn-flex-row-center tn-flex-col-center">
<text v-if="loading" class="tn-icon-loading tn-margin-right-xs spin"></text>
{{ loading ? t('refreshing') : t('refreshStatus') }}
{{ loading ? $tr('刷新中...') : $tr('刷新审批状态') }}
</text>
</view>
<view class="custom-btn btn-light tn-margin-top" @click="goToRegistrationRecords">
<text class="tn-text-bold">{{ t('viewRegistrationRecords') }}</text>
<text class="tn-text-bold">{{ $tr('查看注册记录') }}</text>
</view>
</view>
</view>
@@ -80,81 +80,7 @@ export default {
loading: false,
applicationInfo: null,
targetCode: '',
sourceType: '',
i18n: {
zh: {
navTitle: '注册申请结果',
submittedInfoTitle: '已提交信息',
goLogin: '去登录',
resubmitRegister: '重新提交注册申请',
refreshing: '刷新中...',
refreshStatus: '刷新审批状态',
viewRegistrationRecords: '查看注册记录',
unsubmitted: '未提交',
titleUnsubmitted: '您还未提交注册申请',
titlePending: '注册申请已提交',
titleApproved: '注册审批已通过',
titleRejected: '注册审批未通过',
descUnsubmitted: '请先提交注册申请单,审批通过后才算注册成功。',
descPendingRecords: '当前展示的是该申请单的审批状态,可下拉或点击按钮刷新最新结果。',
descPendingDefault: '当前申请正在审批中,审批通过前无法登录。',
descApproved: '您的注册申请已审批通过,现在可以前往登录。',
descRejectedRecords: '当前展示的是该申请单的审批结果,请根据驳回原因修改信息后重新提交注册申请。',
descRejectedDefault: '请根据驳回原因修改信息后重新提交注册申请。',
remarkApproved: '通过备注',
remarkRejected: '驳回原因',
remarkPending: '审批备注',
roleForeign: '外籍人员',
roleDomestic: '中国籍',
labelIdentityType: '人员类型',
labelName: '姓名',
labelAccount: '注册账号',
labelCertificateNo: '证件号',
fallbackNone: '-',
latestDetailMissing: '未查到最新详情,已展示列表记录',
approvedPleaseLogin: '审批已通过,请登录',
fetchStatusFailed: '获取审批状态失败',
statusPending: '审核中',
statusApproved: '已通过',
statusRejected: '已驳回'
},
en: {
navTitle: 'Registration Result',
submittedInfoTitle: 'Submitted Information',
goLogin: 'Sign In',
resubmitRegister: 'Submit Registration Again',
refreshing: 'Refreshing...',
refreshStatus: 'Refresh Status',
viewRegistrationRecords: 'View Registration Records',
unsubmitted: 'Not Submitted',
titleUnsubmitted: 'No registration application submitted yet',
titlePending: 'Registration submitted',
titleApproved: 'Registration approved',
titleRejected: 'Registration was not approved',
descUnsubmitted: 'Please submit a registration application first. Registration is completed only after approval.',
descPendingRecords: 'This page shows the approval status of the selected application. Pull down or tap the button to refresh.',
descPendingDefault: 'Your application is under review and sign-in is unavailable before approval.',
descApproved: 'Your registration is approved and you can sign in now.',
descRejectedRecords: 'This page shows the approval result of the selected application. Please update the information and resubmit based on the rejection reason.',
descRejectedDefault: 'Please update the information and resubmit based on the rejection reason.',
remarkApproved: 'Approval Note',
remarkRejected: 'Rejection Reason',
remarkPending: 'Approval Note',
roleForeign: 'Foreign',
roleDomestic: 'Chinese',
labelIdentityType: 'Identity Type',
labelName: 'Name',
labelAccount: 'Account',
labelCertificateNo: 'Certificate No.',
fallbackNone: '-',
latestDetailMissing: 'Latest details are unavailable. Showing the list record instead.',
approvedPleaseLogin: 'Approved. Please sign in.',
fetchStatusFailed: 'Failed to fetch approval status',
statusPending: 'Under Review',
statusApproved: 'Approved',
statusRejected: 'Rejected'
}
}
sourceType: ''
}
},
computed: {
@@ -173,36 +99,36 @@ export default {
if (typeof status === 'number') {
return this.getApprovalStatusLabelLocal(status)
}
return this.t('unsubmitted')
return this.$tr('未提交')
},
titleText() {
const map = {
unsubmitted: this.t('titleUnsubmitted'),
pending: this.t('titlePending'),
approved: this.t('titleApproved'),
rejected: this.t('titleRejected')
unsubmitted: this.$tr('您还未提交注册申请'),
pending: this.$tr('注册申请已提交'),
approved: this.$tr('注册审批已通过'),
rejected: this.$tr('注册审批未通过')
}
return map[this.authStatus] || map.unsubmitted
},
descText() {
const map = {
unsubmitted: this.t('descUnsubmitted'),
unsubmitted: this.$tr('请先提交注册申请单,审批通过后才算注册成功。'),
pending: this.sourceType === 'registration-records'
? this.t('descPendingRecords')
: this.t('descPendingDefault'),
approved: this.t('descApproved'),
? this.$tr('当前展示的是该申请单的审批状态,可下拉或点击按钮刷新最新结果。')
: this.$tr('当前申请正在审批中,审批通过前无法登录。'),
approved: this.$tr('您的注册申请已审批通过,现在可以前往登录。'),
rejected: this.sourceType === 'registration-records'
? this.t('descRejectedRecords')
: this.t('descRejectedDefault')
? this.$tr('当前展示的是该申请单的审批结果,请根据驳回原因修改信息后重新提交注册申请。')
: this.$tr('请根据驳回原因修改信息后重新提交注册申请。')
}
return map[this.authStatus] || map.unsubmitted
},
approvalRemarkTitle() {
const map = {
approved: this.t('remarkApproved'),
rejected: this.t('remarkRejected'),
pending: this.t('remarkPending'),
unsubmitted: this.t('remarkPending')
approved: this.$tr('通过备注'),
rejected: this.$tr('驳回原因'),
pending: this.$tr('审批备注'),
unsubmitted: this.$tr('审批备注')
}
return map[this.authStatus] || map.pending
},
@@ -223,13 +149,13 @@ export default {
profileSummary() {
const profile = this.applicationInfo || {}
const identityType = profile.passportNumber ? 'foreign' : 'domestic'
const roleText = identityType === 'foreign' ? this.t('roleForeign') : identityType === 'domestic' ? this.t('roleDomestic') : this.t('fallbackNone')
const certificateNo = profile.passportNumber || profile.idCard || this.t('fallbackNone')
const roleText = identityType === 'foreign' ? this.$tr('外籍人员') : identityType === 'domestic' ? this.$tr('中国籍') : this.$tr('-')
const certificateNo = profile.passportNumber || profile.idCard || this.$tr('-')
return [
{ label: this.t('labelIdentityType'), value: roleText },
{ label: this.t('labelName'), value: profile.name || this.t('fallbackNone') },
{ label: this.t('labelAccount'), value: profile.account || this.t('fallbackNone') },
{ label: this.t('labelCertificateNo'), value: certificateNo },
{ label: this.$tr('人员类型'), value: roleText },
{ label: this.$tr('姓名'), value: profile.name || this.$tr('-') },
{ label: this.$tr('注册账号'), value: profile.account || this.$tr('-') },
{ label: this.$tr('证件号'), value: certificateNo },
// { label: '国籍', value: profile.country || profile.nationality || '-' },
// { label: '工作单位', value: profile.workUnit || '-' },
// { label: '兴趣爱好', value: hobbyText }
@@ -267,9 +193,6 @@ export default {
this.refreshStatus()
},
methods: {
t(key) {
return this.$tm('pkgAccount.auth_result.auth_result', key)
},
getWechatCode() {
return new Promise((resolve) => {
// #ifdef MP-WEIXIN
@@ -324,7 +247,7 @@ export default {
if (!target || typeof target !== 'object' || !Object.keys(target).length) {
if (this.applicationInfo && this.applicationCode) {
uni.showToast({
title: this.t('latestDetailMissing'),
title: this.$tr('未查到最新详情,已展示列表记录'),
icon: 'none'
})
return
@@ -334,7 +257,7 @@ export default {
approvalStatus: 1
}
uni.showToast({
title: this.t('approvedPleaseLogin'),
title: this.$tr('审批已通过,请登录'),
icon: 'success'
})
setTimeout(() => {
@@ -354,7 +277,7 @@ export default {
} catch (error) {
console.error('refresh registration status failed', error)
uni.showToast({
title: this.t('fetchStatusFailed'),
title: this.$tr('获取审批状态失败'),
icon: 'none'
})
} finally {
@@ -365,12 +288,12 @@ export default {
return getApprovalStatusLabel(
status,
this.authStatus === 'pending'
? this.t('statusPending')
? this.$tr('审核中')
: this.authStatus === 'approved'
? this.t('statusApproved')
? this.$tr('已通过')
: this.authStatus === 'rejected'
? this.t('statusRejected')
: this.t('unsubmitted'),
? this.$tr('已驳回')
: this.$tr('未提交'),
this.language
)
},