From dbe13d311d4d35f2f33f7c219ef87ee0950632cc Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sun, 9 Feb 2020 19:27:25 +0800 Subject: [PATCH] feat(cascader): locale --- packages/common/Cascader/src/Cascader.vue | 13 +++++++++---- packages/locale/enUS.js | 3 +++ packages/locale/zhCN.js | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/common/Cascader/src/Cascader.vue b/packages/common/Cascader/src/Cascader.vue index 9529f2536..59257f312 100644 --- a/packages/common/Cascader/src/Cascader.vue +++ b/packages/common/Cascader/src/Cascader.vue @@ -22,7 +22,7 @@ :theme="synthesizedTheme" :active="active" :pattern="pattern" - :placeholder="placeholder" + :placeholder="localizedPlaceholder" :selected-option="selectedOption" :selected-options="selectedOptions" :multiple="multiple" @@ -94,6 +94,7 @@ import { getType, traverseWithCallback } from './utils' import asformitem from '../../../mixins/asformitem' import NBasePortal from '../../../base/Portal' import CascaderSelectMenu from './CascaderSelectMenu' +import locale from '../../../mixins/locale' import { rootedOptions, @@ -118,7 +119,7 @@ export default { directives: { clickoutside }, - mixins: [withapp, themeable, asformitem()], + mixins: [withapp, themeable, asformitem(), locale('Cascader')], model: { prop: 'value', event: 'change' @@ -128,13 +129,13 @@ export default { type: Array, default: null }, - // eslint-disable-next-line vue/require-prop-types value: { + type: [String, Number], default: null }, placeholder: { type: String, - default: 'Please Select' + default: undefined }, multiple: { type: Boolean, @@ -202,6 +203,10 @@ export default { }, computed: { type: getType, + localizedPlaceholder () { + if (this.placeholder !== undefined) return this.placeholder + return this.localeNamespace.placeholder + }, enableAllOptions () { return !this.leafOnly }, diff --git a/packages/locale/enUS.js b/packages/locale/enUS.js index 709c2d9a8..a884ade8d 100644 --- a/packages/locale/enUS.js +++ b/packages/locale/enUS.js @@ -3,6 +3,9 @@ export default { positiveText: 'Confirm', negativeText: 'Cancel' }, + Cascader: { + placeholder: 'Please Select' + }, DatePicker: { Jan: 'Jan', Feb: 'Feb', diff --git a/packages/locale/zhCN.js b/packages/locale/zhCN.js index e196ab536..908790a7a 100644 --- a/packages/locale/zhCN.js +++ b/packages/locale/zhCN.js @@ -3,6 +3,9 @@ export default { positiveText: '确认', negativeText: '取消' }, + Cascader: { + placeholder: '请选择' + }, DatePicker: { Jan: '一月', Feb: '二月',