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="section-panel" v-if="facilityList && facilityList.length">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ t('sectionTitle') }}</text>
|
||||
<text class="section-title">{{ $tr('配套设施') }}</text>
|
||||
</view>
|
||||
<view class="facility-grid tn-flex tn-flex-wrap">
|
||||
<view class="facility-item tn-flex tn-flex-direction-column tn-flex-col-center" v-for="(item, index) in facilityList" :key="index">
|
||||
@@ -24,11 +24,7 @@ export default {
|
||||
default: 'zh'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t(key) {
|
||||
return this.$tm('pkgExplore.store_detail.store_detail', key)
|
||||
}
|
||||
}
|
||||
methods: {}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="section-panel room-section">
|
||||
<view class="section-header tn-flex tn-flex-row-between tn-flex-col-center">
|
||||
<text class="section-title">{{ t('roomSectionTitle', { count: roomTypes.length }) }}</text>
|
||||
<text class="section-title">{{ $tr('在租房型({count})', { count: roomTypes.length }) }}</text>
|
||||
</view>
|
||||
<view class="room-list-vertical">
|
||||
<view
|
||||
@@ -28,11 +28,11 @@
|
||||
<view class="room-bottom-v tn-flex tn-flex-row-between tn-flex-col-bottom">
|
||||
<view class="room-price-v">
|
||||
<text class="price-symbol">¥</text>
|
||||
<text class="price-val">{{ formatPriceValue(room.price) || t('pricePending') }}</text>
|
||||
<text class="price-unit">{{ t('priceUnit') }}</text>
|
||||
<text class="price-val">{{ formatPriceValue(room.price) || $tr('待定') }}</text>
|
||||
<text class="price-unit">{{ $tr('/月') }}</text>
|
||||
</view>
|
||||
<view class="go-btn-v tn-flex tn-flex-col-center tn-flex-row-center">
|
||||
<text>{{ t('viewDetails') }}</text>
|
||||
<text>{{ $tr('查看详情') }}</text>
|
||||
<text class="tn-icon-right"></text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -65,9 +65,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t(key, params = {}) {
|
||||
return this.$tm('pkgExplore.store_detail.store_detail', key, params)
|
||||
},
|
||||
formatPriceValue(priceText) {
|
||||
if (!priceText) {
|
||||
return ''
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<text class="address-title tn-text-ellipsis">{{ shortAddress }}</text>
|
||||
</view>
|
||||
<view class="address-right tn-flex tn-flex-col-center">
|
||||
<text class="nav-text">{{ t('navigate') }}</text>
|
||||
<text class="nav-text">{{ $tr('导航') }}</text>
|
||||
<text class="tn-icon-right nav-arrow"></text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -17,7 +17,7 @@
|
||||
<!-- 小区简介 -->
|
||||
<view class="section-panel" v-if="displayDescription">
|
||||
<view class="section-header">
|
||||
<text class="section-title">{{ t('storeIntro') }}</text>
|
||||
<text class="section-title">{{ $tr('小区简介') }}</text>
|
||||
</view>
|
||||
<view
|
||||
class="store-desc"
|
||||
@@ -29,7 +29,7 @@
|
||||
<text v-else>{{ displayDescription }}</text>
|
||||
</view>
|
||||
<view v-if="shouldShowToggle" class="expand-btn tn-flex tn-flex-row-center tn-flex-col-center" @click="toggleDesc">
|
||||
<text>{{ isDescCollapsed ? t('expandAll') : t('collapse') }}</text>
|
||||
<text>{{ isDescCollapsed ? $tr('展开全部') : $tr('收起') }}</text>
|
||||
<text :class="isDescCollapsed ? 'tn-icon-down' : 'tn-icon-up'" class="expand-icon"></text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -104,19 +104,16 @@ export default {
|
||||
? (this.storeData.addressEnDisplay || this.storeData.addressEn || this.storeData.address || '')
|
||||
: (this.storeData.address || this.storeData.addressEn || '')
|
||||
if (!addr) {
|
||||
return this.t('noAddress')
|
||||
return this.$tr('暂无地址')
|
||||
}
|
||||
if (this.language === 'en') {
|
||||
return addr
|
||||
}
|
||||
const short = addr.replace(/^(?:.*?省|.*?自治区)?(?:.*?市|.*?自治州)?/, '');
|
||||
return short.trim() ? short : (addr || this.t('noAddress'));
|
||||
return short.trim() ? short : (addr || this.$tr('暂无地址'));
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t(key) {
|
||||
return this.$tm('pkgExplore.store_detail.store_detail', key)
|
||||
},
|
||||
toggleDesc() {
|
||||
this.isDescCollapsed = !this.isDescCollapsed;
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<image class="bg-image" :src="image" mode="aspectFill"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view v-else class="bg-empty tn-flex tn-flex-col-center tn-flex-row-center">{{ t('noImage') }}</view>
|
||||
<view v-else class="bg-empty tn-flex tn-flex-col-center tn-flex-row-center">{{ $tr('暂无图片') }}</view>
|
||||
<!-- 渐变暗化遮罩,确保上层文字卡片清晰 -->
|
||||
<view class="bg-mask"></view>
|
||||
</view>
|
||||
@@ -88,7 +88,7 @@
|
||||
<view class="action-bar">
|
||||
<button class="action-btn action-btn--glass" open-type="share">
|
||||
<text class="tn-icon-share action-btn__icon"></text>
|
||||
<text>{{ t('share') }}</text>
|
||||
<text>{{ $tr('分享') }}</text>
|
||||
</button>
|
||||
<button class="action-btn action-btn--primary-glass" @click="handleCall">
|
||||
<text class="tn-icon-phone action-btn__icon"></text>
|
||||
@@ -165,9 +165,9 @@ export default {
|
||||
},
|
||||
displayStoreName() {
|
||||
if (this.language === 'en') {
|
||||
return this.storeData.nameEnDisplay || this.storeData.nameEn || this.storeData.name || this.t('apartmentName')
|
||||
return this.storeData.nameEnDisplay || this.storeData.nameEn || this.storeData.name || this.$tr('公寓详情')
|
||||
}
|
||||
return this.storeData.name || this.storeData.nameEn || this.t('apartmentName')
|
||||
return this.storeData.name || this.storeData.nameEn || this.$tr('公寓详情')
|
||||
},
|
||||
displayStoreAddress() {
|
||||
if (this.language === 'en') {
|
||||
@@ -214,15 +214,15 @@ export default {
|
||||
},
|
||||
contactButtonText() {
|
||||
if (this.isAreaManagerLoading) {
|
||||
return this.t('loading')
|
||||
return this.$tr('加载中...')
|
||||
}
|
||||
if (this.areaManagerOptions.length > 1) {
|
||||
return this.t('selectContact')
|
||||
return this.$tr('选择联系人')
|
||||
}
|
||||
if (this.areaManagerName) {
|
||||
return this.t('contactManager')
|
||||
return this.$tr('联系管家')
|
||||
}
|
||||
return this.t('phoneConsult')
|
||||
return this.$tr('电话咨询')
|
||||
},
|
||||
navBarBackStyle() {
|
||||
const isDarkBg = this.scrollTop < 100;
|
||||
@@ -253,29 +253,26 @@ export default {
|
||||
this.applyStoreData(data)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(this.t('parseStoreDataFailed'), e);
|
||||
console.error(this.$tr('解析小区数据失败'), e);
|
||||
})
|
||||
return
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: this.displayStoreName || this.t('shareTitle'),
|
||||
title: this.displayStoreName || this.$tr('小区详情'),
|
||||
path: `/pkgExplore/store_detail/store_detail?storeData=${encodeURIComponent(JSON.stringify(this.storeData || {}))}`,
|
||||
imageUrl: this.heroImage || ''
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.displayStoreName || this.t('shareTitle'),
|
||||
title: this.displayStoreName || this.$tr('小区详情'),
|
||||
query: `storeData=${encodeURIComponent(JSON.stringify(this.storeData || {}))}`,
|
||||
imageUrl: this.heroImage || ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t(key) {
|
||||
return this.$tm('pkgExplore.store_detail.store_detail', key)
|
||||
},
|
||||
applyStoreData(data) {
|
||||
this.storeData = data && typeof data === 'object' ? data : {}
|
||||
this.roomTypes = this.storeData.roomTypes || []
|
||||
@@ -333,16 +330,16 @@ export default {
|
||||
},
|
||||
getManagerActionText(manager) {
|
||||
if (!manager) {
|
||||
return this.t('phoneConsult')
|
||||
return this.$tr('电话咨询')
|
||||
}
|
||||
if (manager.displayName && manager.phone) {
|
||||
return `${manager.displayName}(${manager.phone})`
|
||||
}
|
||||
return manager.displayName || manager.phone || this.t('phoneConsult')
|
||||
return manager.displayName || manager.phone || this.$tr('电话咨询')
|
||||
},
|
||||
makePhoneCall(phoneNumber) {
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({ title: this.t('noServicePhone'), icon: 'none' })
|
||||
uni.showToast({ title: this.$tr('暂无联系电话'), icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.makePhoneCall({
|
||||
@@ -360,7 +357,7 @@ export default {
|
||||
const longitude = parseCoordinate(this.storeData.longitude, this.storeData.lng)
|
||||
if (latitude === null || longitude === null) {
|
||||
uni.showToast({
|
||||
title: this.t('noLocation'),
|
||||
title: this.$tr('暂无位置信息'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
@@ -368,7 +365,7 @@ export default {
|
||||
uni.openLocation({
|
||||
latitude,
|
||||
longitude,
|
||||
name: this.displayStoreName || this.t('apartmentName'),
|
||||
name: this.displayStoreName || this.$tr('公寓详情'),
|
||||
address: this.displayStoreAddress || '',
|
||||
scale: 18
|
||||
});
|
||||
@@ -390,7 +387,7 @@ export default {
|
||||
},
|
||||
handleCall() {
|
||||
if (this.isAreaManagerLoading && !this.contactPhoneNumber) {
|
||||
uni.showToast({ title: this.t('loadingManagerInfo'), icon: 'none' })
|
||||
uni.showToast({ title: this.$tr('正在加载管家信息'), icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user