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:
@@ -44,22 +44,22 @@
|
||||
</view>
|
||||
|
||||
<view v-if="showPreferenceSelectors" class="form-item tn-margin-top">
|
||||
<view class="form-label">{{ t('hobbyLabel') }}</view>
|
||||
<view class="form-label">{{ $tr('兴趣爱好') }}</view>
|
||||
<tag-selector
|
||||
v-model="form.hobbiesAndInterestsTagKeys"
|
||||
:options="hobbyOptions"
|
||||
:loading="dictLoading"
|
||||
:emptyText="t('emptyHobbyTags')"
|
||||
:emptyText="$tr('暂无兴趣爱好标签')"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view v-if="showPreferenceSelectors" class="form-item tn-margin-top">
|
||||
<view class="form-label">{{ t('lifestyleLabel') }}</view>
|
||||
<view class="form-label">{{ $tr('生活习惯') }}</view>
|
||||
<tag-selector
|
||||
v-model="form.lifestyleHabitsTagKeys"
|
||||
:options="lifestyleOptions"
|
||||
:loading="dictLoading"
|
||||
:emptyText="t('emptyLifestyleTags')"
|
||||
:emptyText="$tr('暂无生活习惯标签')"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
</view>
|
||||
|
||||
<view class="form-item tn-margin-top">
|
||||
<view class="form-label">{{ t('remarkLabel') }}</view>
|
||||
<view class="form-label">{{ $tr('补充说明') }}</view>
|
||||
<textarea class="form-textarea" :placeholder="remarkPlaceholder" v-model="form.remark"></textarea>
|
||||
</view>
|
||||
|
||||
<view v-if="!showFloatingSubmitBtn" class="submit-btn btn-primary tn-margin-top-xl" :class="{ 'submit-btn--disabled': isSubmitting }" @click="submitRequest">
|
||||
<text class="tn-text-bold">{{ isSubmitting ? t('submitting') : primaryActionText }}</text>
|
||||
<text class="tn-text-bold">{{ isSubmitting ? $tr('提交中...') : primaryActionText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -91,7 +91,7 @@
|
||||
<view v-if="showFloatingSubmitBtn" class="floating-submit-bar">
|
||||
<view class="floating-submit-bar__inner">
|
||||
<view class="submit-btn btn-primary" :class="{ 'submit-btn--disabled': isSubmitting }" @click="submitRequest">
|
||||
<text class="tn-text-bold">{{ isSubmitting ? t('submitting') : primaryActionText }}</text>
|
||||
<text class="tn-text-bold">{{ isSubmitting ? $tr('提交中...') : primaryActionText }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -594,81 +594,7 @@ export default {
|
||||
lifestyleOptions: [],
|
||||
form: createDefaultForm(),
|
||||
scrollTop: 0,
|
||||
lastAutoRemark: '',
|
||||
i18n: {
|
||||
zh: {
|
||||
hobbyLabel: '兴趣爱好',
|
||||
emptyHobbyTags: '暂无兴趣爱好标签',
|
||||
lifestyleLabel: '生活习惯',
|
||||
emptyLifestyleTags: '暂无生活习惯标签',
|
||||
remarkLabel: '补充说明',
|
||||
submitting: '提交中...',
|
||||
roomTypeApplyTitle: '房型申请',
|
||||
roomTypeApplyDesc: '请确认房型、区域、偏好标签和租期信息后提交申请。',
|
||||
roomTypeApplyBlockTitle: '房型申请信息',
|
||||
roomTypeApplyBlockDesc: '已接入真实申请单接口,支持带出房型与区域编码后直接提交。',
|
||||
applyRemarkPlaceholder: '请输入您的申请补充说明',
|
||||
submitRoomTypeApply: '提交房型申请',
|
||||
applyRoomType: '申请房型',
|
||||
leaseRange: '租期时间',
|
||||
expectedCheckin: '预计入住',
|
||||
expectedCheckout: '预计离开',
|
||||
selectCheckinDate: '请选择入住日期',
|
||||
selectCheckoutDate: '请选择离开日期',
|
||||
currentRoom: '当前房间',
|
||||
areaLabel: '所属区域',
|
||||
referencePrice: '参考价格',
|
||||
paymentMethod: '支付方式',
|
||||
applicationType: '申请类型',
|
||||
stayApplyDefaultTitle: '入住申请',
|
||||
stayApplyDefaultDesc: '请填写您的入住意向、生活偏好与预计租期后提交申请单。',
|
||||
sourceDefaultDesc: '请填写您的入住意向、租期和补充说明。',
|
||||
tagLoadFailed: '偏好标签加载失败',
|
||||
remarkRequired: '请输入补充说明',
|
||||
applicationInfo: '申请信息',
|
||||
selectDateStart: '请选择{label}',
|
||||
selectDateEnd: '请选择{label}',
|
||||
dateCannotBefore: '{endLabel}不能早于{startLabel}',
|
||||
submitSuccess: '申请单提交成功',
|
||||
submitFailed: '申请单提交失败'
|
||||
},
|
||||
en: {
|
||||
hobbyLabel: 'Hobbies',
|
||||
emptyHobbyTags: 'No hobby tags',
|
||||
lifestyleLabel: 'Lifestyle Habits',
|
||||
emptyLifestyleTags: 'No lifestyle tags',
|
||||
remarkLabel: 'Additional Notes',
|
||||
submitting: 'Submitting...',
|
||||
roomTypeApplyTitle: 'Room Type Application',
|
||||
roomTypeApplyDesc: 'Confirm the room type, area, preference tags, and lease period before submitting.',
|
||||
roomTypeApplyBlockTitle: 'Application Details',
|
||||
roomTypeApplyBlockDesc: 'The live application API is connected and can submit with room and area codes.',
|
||||
applyRemarkPlaceholder: 'Enter your additional notes',
|
||||
submitRoomTypeApply: 'Submit Application',
|
||||
applyRoomType: 'Requested Room Type',
|
||||
leaseRange: 'Lease Period',
|
||||
expectedCheckin: 'Expected Check-in',
|
||||
expectedCheckout: 'Expected Checkout',
|
||||
selectCheckinDate: 'Select check-in date',
|
||||
selectCheckoutDate: 'Select checkout date',
|
||||
currentRoom: 'Current Room',
|
||||
areaLabel: 'Area',
|
||||
referencePrice: 'Reference Price',
|
||||
paymentMethod: 'Payment Method',
|
||||
applicationType: 'Application Type',
|
||||
stayApplyDefaultTitle: 'Stay Application',
|
||||
stayApplyDefaultDesc: 'Fill in your stay intention, preferences, and lease period before submission.',
|
||||
sourceDefaultDesc: 'Fill in your stay intention, lease period, and notes.',
|
||||
tagLoadFailed: 'Failed to load preference tags',
|
||||
remarkRequired: 'Please enter additional notes',
|
||||
applicationInfo: 'Application Details',
|
||||
selectDateStart: 'Please select {label}',
|
||||
selectDateEnd: 'Please select {label}',
|
||||
dateCannotBefore: '{endLabel} cannot be earlier than {startLabel}',
|
||||
submitSuccess: 'Application submitted',
|
||||
submitFailed: 'Failed to submit application'
|
||||
}
|
||||
}
|
||||
lastAutoRemark: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -709,52 +635,52 @@ export default {
|
||||
pageTitle() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.language === 'en'
|
||||
? compactEnglishText(this.t('roomTypeApplyTitle'), 22)
|
||||
: this.t('roomTypeApplyTitle')
|
||||
? compactEnglishText(this.$tr('房型申请'), 22)
|
||||
: this.$tr('房型申请')
|
||||
}
|
||||
return this.getBusinessText('titleShort')
|
||||
|| this.getBusinessText('title')
|
||||
|| this.getLocalizedSourceText('title')
|
||||
|| this.t('stayApplyDefaultTitle')
|
||||
|| this.$tr('入住申请')
|
||||
},
|
||||
pageDesc() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.language === 'en'
|
||||
? compactEnglishText(this.t('roomTypeApplyDesc'), 96)
|
||||
: this.t('roomTypeApplyDesc')
|
||||
? compactEnglishText(this.$tr('请确认房型、区域、偏好标签和租期信息后提交申请。'), 96)
|
||||
: this.$tr('请确认房型、区域、偏好标签和租期信息后提交申请。')
|
||||
}
|
||||
const text = this.getBusinessText('desc') || this.getLocalizedSourceText('desc') || this.t('stayApplyDefaultDesc')
|
||||
const text = this.getBusinessText('desc') || this.getLocalizedSourceText('desc') || this.$tr('请填写您的入住意向、生活偏好与预计租期后提交申请单。')
|
||||
return this.language === 'en' ? compactEnglishText(text, 96) : text
|
||||
},
|
||||
formBlockTitle() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.t('roomTypeApplyBlockTitle')
|
||||
return this.$tr('房型申请信息')
|
||||
}
|
||||
return this.getBusinessText('formBlockTitle') || this.t('applicationInfo')
|
||||
return this.getBusinessText('formBlockTitle') || this.$tr('申请信息')
|
||||
},
|
||||
formBlockDesc() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.t('roomTypeApplyBlockDesc')
|
||||
return this.$tr('已接入真实申请单接口,支持带出房型与区域编码后直接提交。')
|
||||
}
|
||||
return this.getBusinessText('formBlockDesc') || this.t('stayApplyDefaultDesc')
|
||||
return this.getBusinessText('formBlockDesc') || this.$tr('请填写您的入住意向、生活偏好与预计租期后提交申请单。')
|
||||
},
|
||||
remarkPlaceholder() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.t('applyRemarkPlaceholder')
|
||||
return this.$tr('请输入您的申请补充说明')
|
||||
}
|
||||
return this.getBusinessText('remarkPlaceholder') || this.t('remarkRequired')
|
||||
return this.getBusinessText('remarkPlaceholder') || this.$tr('请输入补充说明')
|
||||
},
|
||||
primaryActionText() {
|
||||
if (this.isRoomTypeApply) {
|
||||
return this.language === 'en'
|
||||
? compactEnglishText(this.t('submitRoomTypeApply'), 24)
|
||||
: this.t('submitRoomTypeApply')
|
||||
? compactEnglishText(this.$tr('提交房型申请'), 24)
|
||||
: this.$tr('提交房型申请')
|
||||
}
|
||||
const text = this.getBusinessText('primaryActionText') || this.t('submitApplicationFallback')
|
||||
const text = this.getBusinessText('primaryActionText') || this.$tr('提交申请')
|
||||
return this.language === 'en' ? compactEnglishText(text, 24) : text
|
||||
},
|
||||
roomTypeLabel() {
|
||||
return this.getBusinessText('roomTypeLabel') || this.t('applyRoomType')
|
||||
return this.getBusinessText('roomTypeLabel') || this.$tr('申请房型')
|
||||
},
|
||||
pageBottomPadding() {
|
||||
return this.showFloatingSubmitBtn ? '220rpx' : '60rpx'
|
||||
@@ -763,7 +689,7 @@ export default {
|
||||
return this.isRoomTypeApply
|
||||
},
|
||||
floorLabel() {
|
||||
return this.getBusinessText('floorLabel') || this.t('floorLabel')
|
||||
return this.getBusinessText('floorLabel') || this.$tr('楼层')
|
||||
},
|
||||
showRoomTypeSelector() {
|
||||
if (this.isRoomTypeApply) {
|
||||
@@ -790,19 +716,19 @@ export default {
|
||||
return this.businessConfig ? this.businessConfig.showDateRange !== false : true
|
||||
},
|
||||
dateRangeLabel() {
|
||||
return this.getBusinessText('dateRangeLabel') || this.t('leaseRange')
|
||||
return this.getBusinessText('dateRangeLabel') || this.$tr('租期时间')
|
||||
},
|
||||
dateRangeStartLabel() {
|
||||
return this.getBusinessText('dateRangeStartLabel') || this.t('expectedCheckin')
|
||||
return this.getBusinessText('dateRangeStartLabel') || this.$tr('预计入住')
|
||||
},
|
||||
dateRangeEndLabel() {
|
||||
return this.getBusinessText('dateRangeEndLabel') || this.t('expectedCheckout')
|
||||
return this.getBusinessText('dateRangeEndLabel') || this.$tr('预计离开')
|
||||
},
|
||||
dateRangeStartPlaceholder() {
|
||||
return this.getBusinessText('dateRangeStartPlaceholder') || this.t('selectCheckinDate')
|
||||
return this.getBusinessText('dateRangeStartPlaceholder') || this.$tr('请选择入住日期')
|
||||
},
|
||||
dateRangeEndPlaceholder() {
|
||||
return this.getBusinessText('dateRangeEndPlaceholder') || this.t('selectCheckoutDate')
|
||||
return this.getBusinessText('dateRangeEndPlaceholder') || this.$tr('请选择离开日期')
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -839,9 +765,6 @@ export default {
|
||||
this.loadDictOptions()
|
||||
},
|
||||
methods: {
|
||||
t(key, params) {
|
||||
return this.$tm('pkgService.submit_request.submit_request', key, params)
|
||||
},
|
||||
decodeRouteText(value, fallback = '') {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return fallback
|
||||
@@ -1000,7 +923,7 @@ export default {
|
||||
.catch((error) => {
|
||||
console.error('load application dict options failed', error)
|
||||
uni.showToast({
|
||||
title: this.t('tagLoadFailed'),
|
||||
title: this.$tr('偏好标签加载失败'),
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
@@ -1038,20 +961,20 @@ export default {
|
||||
validateForm() {
|
||||
if (this.showDateRange) {
|
||||
if (!this.form.start) {
|
||||
return this.t('selectDateStart', { label: this.dateRangeStartLabel })
|
||||
return this.$tr('请选择{label}', { label: this.dateRangeStartLabel })
|
||||
}
|
||||
if (!this.form.end) {
|
||||
return this.t('selectDateEnd', { label: this.dateRangeEndLabel })
|
||||
return this.$tr('请选择{label}', { label: this.dateRangeEndLabel })
|
||||
}
|
||||
if (new Date(this.form.end).getTime() < new Date(this.form.start).getTime()) {
|
||||
return this.t('dateCannotBefore', {
|
||||
return this.$tr('{endLabel}不能早于{startLabel}', {
|
||||
endLabel: this.dateRangeEndLabel,
|
||||
startLabel: this.dateRangeStartLabel
|
||||
})
|
||||
}
|
||||
}
|
||||
if (!this.form.remark.trim()) {
|
||||
return this.t('remarkRequired')
|
||||
return this.$tr('请输入补充说明')
|
||||
}
|
||||
return ''
|
||||
},
|
||||
@@ -1084,7 +1007,7 @@ export default {
|
||||
|
||||
this.isSubmitting = true
|
||||
uni.showLoading({
|
||||
title: this.t('submitting')
|
||||
title: this.$tr('提交中...')
|
||||
})
|
||||
|
||||
const payload = this.buildSubmitPayload()
|
||||
@@ -1096,7 +1019,7 @@ export default {
|
||||
}
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: this.t('submitSuccess'),
|
||||
title: this.$tr('申请单提交成功'),
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
@@ -1111,7 +1034,7 @@ export default {
|
||||
console.error('submit application form failed', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: (error && (error.message || error.msg)) || this.t('submitFailed'),
|
||||
title: (error && (error.message || error.msg)) || this.$tr('申请单提交失败'),
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user