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

@@ -28,10 +28,10 @@
</view>
<view class="tn-margin tn-padding-top-sm" style="color: #001E50;font-size: 50rpx;">
<text class="tn-text-bold">62,888</text>
<text class="tn-padding-left-xs tn-text-xs tn-color-gray">{{ t('pointsUnit') }}</text>
<text class="tn-padding-left-xs tn-text-xs tn-color-gray">{{ $tr('积分') }}</text>
</view>
<view class="tn-margin tn-text-sm" style="color: #001E50;">
{{ t('pointsRecord') }} <text class="tn-icon-right tn-padding-left-xs tn-color-gray"></text>
{{ $tr('积分记录') }} <text class="tn-icon-right tn-padding-left-xs tn-color-gray"></text>
</view>
</view>
@@ -84,7 +84,7 @@
<!-- 未签到-->
<view class="tn-flex-1 justify-content-item tn-margin-xs tn-text-center">
<tn-button shape="round" backgroundColor="$brand-primary" fontColor="#FFFFFF" padding="40rpx 0" width="100%" :fontSize="30" @tap="showLandscape">
<text class="">{{ t('checkInNow') }}</text>
<text class="">{{ $tr('立即签到') }}</text>
</tn-button>
</view>
@@ -96,12 +96,12 @@
</view> -->
<view class="tn-strip-bottom-min tn-padding" style="color: #95A3A8;">
{{ t('checkInRewardHint') }}
{{ $tr('坚持每天连续签到可以获得多重奖励哦') }}
</view>
<view class="tn-padding-left tn-pright tn-padding-top tn-padding-bottom tn-text-sm" style="color: #95A3A8;">
{{ t('warmTip') }}<br>
{{ t('warmTipDesc') }}
{{ $tr('温馨提示:') }}<br>
{{ $tr('每日签到可获得10积分奖励,连续完成7天签到可能获得额外奖励,连续签到满7天后将会重置签到记录。') }}
</view>
</view>
@@ -110,10 +110,10 @@
<view class="tn-padding-top-sm">
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin" @click="tn('')">
<view class="justify-content-item tn-text-bold tn-text-lg tn-padding-left-xs">
{{ t('taskSectionTitle') }}
{{ $tr('做任务领金币') }}
</view>
<view class="justify-content-item tn-text-df" style="color: #C1CACF;">
<text class="tn-padding-xs">{{ t('more') }}</text>
<text class="tn-padding-xs">{{ $tr('更多') }}</text>
<text class="tn-icon-right"></text>
</view>
</view>
@@ -130,7 +130,7 @@
</view>
<view class="justify-content-item">
<tn-button shape="round" size="sm" backgroundColor="$brand-primary" fontColor="#FFFFFF" padding="30rpx 0" width="160rpx">
<text class="tn-text-bold tn-text-sm">{{ t('goComplete') }}</text>
<text class="tn-text-bold tn-text-sm">{{ $tr('去完成') }}</text>
<text class="tn-icon-right-fill tn-padding-left-xs tn-text-lg"></text>
</tn-button>
</view>
@@ -156,19 +156,19 @@
<image src="https://cdn.nlark.com/yuque/0/2024/png/280373/1719936460577-assets/web-upload/697ed6f1-6126-4734-bd80-bed28296e16d.png" mode="aspectFit" style="width: 320rpx;height: 330rpx;"></image>
</view>
<view class="tn-text-xl tn-text-bold" style="padding-top: 120rpx;">
{{ t('checkInSuccess') }}
{{ $tr('签到成功') }}
</view>
<view class="tn-padding tn-color-gray--dark">
<text>{{ t('checkedInFor') }}</text>
<text>{{ $tr('已连续签到') }}</text>
<text class="tn-color-orangered" style="padding-left: 6rpx;padding-right: 6rpx">3</text>
<text>{{ t('daysAndEarned') }}</text>
<text>{{ $tr('天,获得') }}</text>
<text class="tn-color-orangered" style="padding-left: 6rpx;padding-right: 6rpx">20</text>
<text>{{ t('pointsUnit') }}</text>
<text>{{ $tr('积分') }}</text>
</view>
<view class=" tn-padding tn-color-gray">
<text>{{ t('continuousCheckIn') }}</text>
<text>{{ $tr('连续签到') }}</text>
<text class="tn-color-orangered" style="padding-left: 6rpx;padding-right: 6rpx;">7</text>
<text>{{ t('daysRewardHint') }}</text>
<text>{{ $tr('天可获得额外奖励哦!') }}</text>
</view>
</view>
@@ -186,50 +186,6 @@
export default {
name: 'Sign',
mixins: [template_page_mixin],
i18n: {
zh: {
pointsUnit: '积分',
pointsRecord: '积分记录',
checkInNow: '立即签到',
checkInRewardHint: '坚持每天连续签到可以获得多重奖励哦',
warmTip: '温馨提示:',
warmTipDesc: '每日签到可获得10积分奖励,连续完成7天签到可能获得额外奖励,连续签到满7天后将会重置签到记录。',
taskSectionTitle: '做任务领金币',
more: '更多',
goComplete: '去完成',
checkInSuccess: '签到成功',
checkedInFor: '已连续签到',
daysAndEarned: '天,获得',
continuousCheckIn: '连续签到',
daysRewardHint: '天可获得额外奖励哦!',
notice1: '恭喜 付*其 连续7天签到,获得 300积分 奖励',
notice2: '恭喜 徐*圆 连续7天签到,获得 300积分 奖励',
notice3: '恭喜 蔡*东 连续7天签到,获得 300积分 奖励',
taskName: '任务名称',
taskDesc: '抓住那只猪吖'
},
en: {
pointsUnit: 'Points',
pointsRecord: 'Points History',
checkInNow: 'Check In Now',
checkInRewardHint: 'Daily continuous check-ins unlock multiple rewards',
warmTip: 'Tips:',
warmTipDesc: 'Daily check-in grants 10 points. Completing 7 consecutive days may unlock extra rewards, and the record resets after day 7.',
taskSectionTitle: 'Complete Tasks for Coins',
more: 'More',
goComplete: 'Go',
checkInSuccess: 'Check-in Successful',
checkedInFor: 'Checked in for',
daysAndEarned: 'days and earned',
continuousCheckIn: 'Continuous check-in',
daysRewardHint: 'days unlocks extra rewards!',
notice1: 'Congrats to Fu*qi for 7 consecutive check-ins and earning 300 points',
notice2: 'Congrats to Xu*yuan for 7 consecutive check-ins and earning 300 points',
notice3: 'Congrats to Cai*dong for 7 consecutive check-ins and earning 300 points',
taskName: 'Task Name',
taskDesc: 'Catch That Pig'
}
},
data(){
return {
show: true,
@@ -238,19 +194,16 @@
},
computed: {
noticeList() {
return [this.t('notice1'), this.t('notice2'), this.t('notice3')]
return [this.$tr('恭喜 付*其 连续7天签到,获得 300积分 奖励'), this.$tr('恭喜 徐*圆 连续7天签到,获得 300积分 奖励'), this.$tr('恭喜 蔡*东 连续7天签到,获得 300积分 奖励')]
},
taskList() {
return Array.from({ length: 6 }).map(() => ({
title: this.t('taskName'),
desc: this.t('taskDesc')
title: this.$tr('任务名称'),
desc: this.$tr('抓住那只猪吖')
}))
}
},
methods: {
t(key, params) {
return this.$tm('pkgExplore.sign.sign', key, params)
},
// 跳转
tn(e) {
uni.navigateTo({