mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-25 02:41:46 +08:00
fix(Sku): unextracted i18n message (#4172)
This commit is contained in:
parent
71501d0ac1
commit
85ab52dab5
@ -13,7 +13,9 @@ import { createNamespace, isDef } from '../utils';
|
|||||||
import { isAllSelected, isSkuChoosable, getSkuComb, getSelectedSkuValues } from './utils/skuHelper';
|
import { isAllSelected, isSkuChoosable, getSkuComb, getSelectedSkuValues } from './utils/skuHelper';
|
||||||
import { LIMIT_TYPE, UNSELECTED_SKU_VALUE_ID } from './constants';
|
import { LIMIT_TYPE, UNSELECTED_SKU_VALUE_ID } from './constants';
|
||||||
|
|
||||||
const [createComponent] = createNamespace('sku');
|
const namespace = createNamespace('sku');
|
||||||
|
const createComponent = namespace[0];
|
||||||
|
const t = namespace[2];
|
||||||
const { QUOTA_LIMIT } = LIMIT_TYPE;
|
const { QUOTA_LIMIT } = LIMIT_TYPE;
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
@ -216,7 +218,7 @@ export default createComponent({
|
|||||||
const { stockFormatter } = this.customStepperConfig;
|
const { stockFormatter } = this.customStepperConfig;
|
||||||
if (stockFormatter) return stockFormatter(this.stock);
|
if (stockFormatter) return stockFormatter(this.stock);
|
||||||
|
|
||||||
return `剩余 ${this.stock}件`;
|
return t('stock', this.stock);
|
||||||
},
|
},
|
||||||
|
|
||||||
quotaText() {
|
quotaText() {
|
||||||
@ -229,7 +231,7 @@ export default createComponent({
|
|||||||
if (quotaText) {
|
if (quotaText) {
|
||||||
text = quotaText;
|
text = quotaText;
|
||||||
} else if (this.quota > 0) {
|
} else if (this.quota > 0) {
|
||||||
text = `每人限购${this.quota}件`;
|
text = t('quotaLimit', this.quota);
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
@ -237,7 +239,7 @@ export default createComponent({
|
|||||||
|
|
||||||
selectedText() {
|
selectedText() {
|
||||||
if (this.selectedSkuComb) {
|
if (this.selectedSkuComb) {
|
||||||
return `已选 ${this.selectedSkuValues.map(item => item.name).join(';')}`;
|
return `${t('selected')} ${this.selectedSkuValues.map(item => item.name).join(';')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unselected = this.skuTree
|
const unselected = this.skuTree
|
||||||
@ -245,7 +247,7 @@ export default createComponent({
|
|||||||
.map(item => item.k)
|
.map(item => item.k)
|
||||||
.join(';');
|
.join(';');
|
||||||
|
|
||||||
return `选择 ${unselected}`;
|
return `${t('select')} ${unselected}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -316,7 +318,7 @@ export default createComponent({
|
|||||||
|
|
||||||
validateSku() {
|
validateSku() {
|
||||||
if (this.selectedNum === 0) {
|
if (this.selectedNum === 0) {
|
||||||
return '商品已经无法购买啦';
|
return t('unavailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isSkuCombSelected) {
|
if (this.isSkuCombSelected) {
|
||||||
@ -329,7 +331,7 @@ export default createComponent({
|
|||||||
if (err) return err;
|
if (err) return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '请先选择商品规格';
|
return t('selectSku');
|
||||||
},
|
},
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
@ -385,14 +387,14 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'minus') {
|
if (action === 'minus') {
|
||||||
Toast('至少选择一件');
|
Toast(t('minusTip'));
|
||||||
} else if (action === 'plus') {
|
} else if (action === 'plus') {
|
||||||
if (limitType === QUOTA_LIMIT) {
|
if (limitType === QUOTA_LIMIT) {
|
||||||
let msg = `限购${quota}件`;
|
let msg = t('quotaLimit', quota);
|
||||||
if (quotaUsed > 0) msg += `,${`你已购买${quotaUsed}件`}`;
|
if (quotaUsed > 0) msg += `,${t('quotaCount', quotaUsed)}`;
|
||||||
Toast(msg);
|
Toast(msg);
|
||||||
} else {
|
} else {
|
||||||
Toast('库存不足');
|
Toast(t('soldout'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -464,7 +466,7 @@ export default createComponent({
|
|||||||
)}
|
)}
|
||||||
{slots('sku-header-origin-price') || (
|
{slots('sku-header-origin-price') || (
|
||||||
originPrice && (
|
originPrice && (
|
||||||
<SkuHeaderItem>原价 ¥{originPrice}</SkuHeaderItem>
|
<SkuHeaderItem>{t('originPrice')} ¥{originPrice}</SkuHeaderItem>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{!this.hideStock && (
|
{!this.hideStock && (
|
||||||
|
@ -4,6 +4,18 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
|
vanSku: {
|
||||||
|
select: '选择',
|
||||||
|
selected: '已选',
|
||||||
|
selectSku: '请先选择商品规格',
|
||||||
|
soldout: '库存不足',
|
||||||
|
originPrice: '原价',
|
||||||
|
minusTip: '至少选择一件',
|
||||||
|
unavailable: '商品已经无法购买啦',
|
||||||
|
stock: (stock: number) => `剩余 ${stock}件`,
|
||||||
|
quotaLimit: (quota: number) => `每人限购${quota}件`,
|
||||||
|
quotaCount: (count: number) => `你已购买${count}件`
|
||||||
|
},
|
||||||
vanSkuActions: {
|
vanSkuActions: {
|
||||||
buy: '立即购买',
|
buy: '立即购买',
|
||||||
addCart: '加入购物车'
|
addCart: '加入购物车'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user