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:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="message-detail-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-main tn-padding" :style="{ paddingTop: vuex_custom_bar_height + 'px', paddingBottom: '48rpx' }">
|
||||
@@ -12,7 +12,7 @@
|
||||
<text :class="categoryIcon"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="hero-title tn-margin-top">{{ localizedTitle || t('messageFallbackTitle') }}</view>
|
||||
<view class="hero-title tn-margin-top">{{ localizedTitle || $tr('消息通知') }}</view>
|
||||
<view class="hero-meta-row tn-margin-top">
|
||||
<view class="hero-meta-chip">
|
||||
<text class="tn-icon-time tn-margin-right-xs"></text>
|
||||
@@ -26,7 +26,7 @@
|
||||
</view>
|
||||
|
||||
<view class="article-header tn-margin-bottom-lg">
|
||||
<view class="article-title">{{ localizedTitle || t('messageFallbackTitle') }}</view>
|
||||
<view class="article-title">{{ localizedTitle || $tr('消息通知') }}</view>
|
||||
<view class="article-meta tn-margin-top">
|
||||
<view class="article-tag">{{ categoryText }}</view>
|
||||
<view class="article-time">{{ detail.time || '--' }}</view>
|
||||
@@ -34,42 +34,42 @@
|
||||
</view>
|
||||
|
||||
<view class="content-panel tn-margin-bottom-lg">
|
||||
<view class="panel-title">{{ t('contentTitle') }}</view>
|
||||
<view class="panel-title">{{ $tr('通知内容') }}</view>
|
||||
<rich-text class="article-content tn-margin-top" :nodes="contentNodes"></rich-text>
|
||||
</view>
|
||||
|
||||
<view v-if="localizedDesc && localizedDesc !== localizedContent" class="content-panel tn-margin-bottom-lg">
|
||||
<view class="panel-title">{{ t('summaryTitle') }}</view>
|
||||
<view class="panel-title">{{ $tr('摘要') }}</view>
|
||||
<view class="panel-desc tn-margin-top">{{ localizedDesc }}</view>
|
||||
</view>
|
||||
|
||||
<view class="meta-panel tn-margin-bottom-lg">
|
||||
<view class="meta-row">
|
||||
<text class="meta-label">{{ t('sourceLabel') }}</text>
|
||||
<text class="meta-label">{{ $tr('消息来源') }}</text>
|
||||
<text class="meta-value">{{ sourceText }}</text>
|
||||
</view>
|
||||
<view class="meta-row">
|
||||
<text class="meta-label">{{ t('categoryLabel') }}</text>
|
||||
<text class="meta-label">{{ $tr('消息分类') }}</text>
|
||||
<text class="meta-value">{{ categoryText }}</text>
|
||||
</view>
|
||||
<view v-if="detail.code" class="meta-row">
|
||||
<text class="meta-label">{{ t('codeLabel') }}</text>
|
||||
<text class="meta-label">{{ $tr('通知编码') }}</text>
|
||||
<view class="meta-action-wrap">
|
||||
<text class="meta-value">{{ detail.code }}</text>
|
||||
<view class="copy-btn" @click="copyCode">
|
||||
<text class="tn-text-xs tn-text-bold">{{ t('copy') }}</text>
|
||||
<text class="tn-text-xs tn-text-bold">{{ $tr('复制') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="detail.statusHint" class="meta-row">
|
||||
<text class="meta-label">{{ t('statusLabel') }}</text>
|
||||
<text class="meta-label">{{ $tr('当前状态') }}</text>
|
||||
<text class="meta-value">{{ detail.statusHint }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="action-row">
|
||||
<view class="ghost-btn" @click="goBackList">
|
||||
<text class="tn-text-bold">{{ t('backList') }}</text>
|
||||
<text class="tn-text-bold">{{ $tr('返回消息页') }}</text>
|
||||
</view>
|
||||
<view v-if="detail.path" class="action-btn" @click="handleGoBusiness">
|
||||
<text class="tn-text-bold">{{ actionButtonText }}</text>
|
||||
@@ -111,58 +111,6 @@ function normalizeContentToRichText(value = '', emptyText = '') {
|
||||
}
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
zh: {
|
||||
navTitle: '消息详情',
|
||||
messageFallbackTitle: '消息通知',
|
||||
contentTitle: '通知内容',
|
||||
summaryTitle: '摘要',
|
||||
sourceLabel: '消息来源',
|
||||
categoryLabel: '消息分类',
|
||||
codeLabel: '通知编码',
|
||||
copy: '复制',
|
||||
statusLabel: '当前状态',
|
||||
backList: '返回消息页',
|
||||
categorySystem: '系统通知',
|
||||
categoryPayment: '缴费账单',
|
||||
categoryButler: '管家消息',
|
||||
actionSystem: '前往相关页面',
|
||||
actionPayment: '去处理账单',
|
||||
actionButler: '去查看服务',
|
||||
actionDefault: '继续前往业务页',
|
||||
remoteSource: '系统通知接口',
|
||||
localSource: '本地业务消息',
|
||||
expiredDesc: '当前消息详情已失效,请返回消息中心重新打开。',
|
||||
expiredHint: '消息缓存已失效',
|
||||
codeCopied: '通知编号已复制',
|
||||
emptyContent: '暂无详细内容'
|
||||
},
|
||||
en: {
|
||||
navTitle: 'Message Detail',
|
||||
messageFallbackTitle: 'Notification',
|
||||
contentTitle: 'Content',
|
||||
summaryTitle: 'Summary',
|
||||
sourceLabel: 'Source',
|
||||
categoryLabel: 'Category',
|
||||
codeLabel: 'Notice Code',
|
||||
copy: 'Copy',
|
||||
statusLabel: 'Status',
|
||||
backList: 'Back to Messages',
|
||||
categorySystem: 'System Notice',
|
||||
categoryPayment: 'Payment Bill',
|
||||
categoryButler: 'Butler Message',
|
||||
actionSystem: 'Open Related Page',
|
||||
actionPayment: 'Handle Bill',
|
||||
actionButler: 'View Service',
|
||||
actionDefault: 'Continue to Page',
|
||||
remoteSource: 'Remote Notification API',
|
||||
localSource: 'Local Business Message',
|
||||
expiredDesc: 'This message detail has expired. Please return to the message center and open it again.',
|
||||
expiredHint: 'Message cache expired',
|
||||
codeCopied: 'Notice code copied',
|
||||
emptyContent: 'No detailed content available'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
lookupId: '',
|
||||
@@ -205,14 +153,14 @@ export default {
|
||||
},
|
||||
categoryText() {
|
||||
const map = {
|
||||
system: this.t('categorySystem'),
|
||||
payment: this.t('categoryPayment'),
|
||||
butler: this.t('categoryButler')
|
||||
system: this.$tr('系统通知'),
|
||||
payment: this.$tr('缴费账单'),
|
||||
butler: this.$tr('管家消息')
|
||||
}
|
||||
return map[this.detail.category] || this.t('messageFallbackTitle')
|
||||
return map[this.detail.category] || this.$tr('消息通知')
|
||||
},
|
||||
contentNodes() {
|
||||
return normalizeContentToRichText(this.localizedContent || this.localizedDesc || '', this.t('emptyContent'))
|
||||
return normalizeContentToRichText(this.localizedContent || this.localizedDesc || '', this.$tr('暂无详细内容'))
|
||||
},
|
||||
categoryIcon() {
|
||||
const map = {
|
||||
@@ -240,14 +188,14 @@ export default {
|
||||
},
|
||||
actionButtonText() {
|
||||
const map = {
|
||||
system: this.t('actionSystem'),
|
||||
payment: this.t('actionPayment'),
|
||||
butler: this.t('actionButler')
|
||||
system: this.$tr('前往相关页面'),
|
||||
payment: this.$tr('去处理账单'),
|
||||
butler: this.$tr('去查看服务')
|
||||
}
|
||||
return map[this.detail.category] || this.t('actionDefault')
|
||||
return map[this.detail.category] || this.$tr('继续前往业务页')
|
||||
},
|
||||
sourceText() {
|
||||
return this.detail.source === 'remote' ? this.t('remoteSource') : this.t('localSource')
|
||||
return this.detail.source === 'remote' ? this.$tr('系统通知接口') : this.$tr('本地业务消息')
|
||||
}
|
||||
},
|
||||
onLoad(options = {}) {
|
||||
@@ -264,9 +212,6 @@ export default {
|
||||
clearMessageDetailPayload(this.language)
|
||||
},
|
||||
methods: {
|
||||
t(key, params) {
|
||||
return this.$tm('pkgService.message_detail.message_detail', key, params)
|
||||
},
|
||||
restoreDetail() {
|
||||
const payload = getMessageDetailPayload(this.language)
|
||||
const fallbackPayload = findMessageDetailPayload(this.lookupId, this.lookupCode, this.language)
|
||||
@@ -284,17 +229,17 @@ export default {
|
||||
...this.detail,
|
||||
id: this.lookupId || this.lookupCode || '',
|
||||
code: this.lookupCode || '',
|
||||
titleZh: this.t('messageFallbackTitle'),
|
||||
titleEn: this.t('messageFallbackTitle'),
|
||||
descZh: this.t('expiredDesc'),
|
||||
descEn: this.t('expiredDesc'),
|
||||
contentZh: this.t('expiredDesc'),
|
||||
contentEn: this.t('expiredDesc'),
|
||||
title: this.t('messageFallbackTitle'),
|
||||
desc: this.t('expiredDesc'),
|
||||
content: this.t('expiredDesc'),
|
||||
titleZh: this.$tr('消息通知'),
|
||||
titleEn: this.$tr('消息通知'),
|
||||
descZh: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
descEn: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
contentZh: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
contentEn: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
title: this.$tr('消息通知'),
|
||||
desc: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
content: this.$tr('当前消息详情已失效,请返回消息中心重新打开。'),
|
||||
source: 'remote',
|
||||
statusHint: this.t('expiredHint')
|
||||
statusHint: this.$tr('消息缓存已失效')
|
||||
}
|
||||
},
|
||||
goBackList() {
|
||||
@@ -308,7 +253,7 @@ export default {
|
||||
data: String(this.detail.code),
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: this.t('codeCopied'),
|
||||
title: this.$tr('通知编号已复制'),
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user