Locale: fix dynamic change locale

This commit is contained in:
qingwei.li 2016-11-17 15:37:04 +08:00 committed by Leopoldthecoder
parent faa27b9d99
commit a13b49b609
7 changed files with 23 additions and 20 deletions

View File

@ -1,10 +1,5 @@
import { t } from 'element-ui/src/locale';
const CONFIRM_TEXT = t('el.messagebox.confirm');
const CANCEL_TEXT = t('el.messagebox.cancel');
const defaults = {
title: '提示',
title: undefined,
message: '',
type: '',
showInput: false,
@ -22,8 +17,8 @@ const defaults = {
confirmButtonPosition: 'right',
confirmButtonHighlight: false,
cancelButtonHighlight: false,
confirmButtonText: CONFIRM_TEXT,
cancelButtonText: CANCEL_TEXT,
confirmButtonText: '',
cancelButtonText: '',
confirmButtonClass: '',
cancelButtonClass: ''
};

View File

@ -2,8 +2,8 @@
<transition name="msgbox-fade">
<div class="el-message-box__wrapper" v-show="value" @click.self="handleWrapperClick">
<div class="el-message-box">
<div class="el-message-box__header" v-if="title !== ''">
<div class="el-message-box__title">{{ title }}</div>
<div class="el-message-box__header" v-if="title !== undefined">
<div class="el-message-box__title">{{ title || t('el.messagebox.title') }}</div>
<i class="el-message-box__close el-icon-close" @click="handleAction('cancel')" v-if="showClose"></i>
</div>
<div class="el-message-box__content" v-if="message !== ''">
@ -15,8 +15,8 @@
</div>
</div>
<div class="el-message-box__btns">
<el-button :class="[ cancelButtonClasses ]" v-show="showCancelButton" @click.native="handleAction('cancel')">{{ cancelButtonText }}</el-button>
<el-button ref="confirm" :class="[ confirmButtonClasses ]" v-show="showConfirmButton" @click.native="handleAction('confirm')">{{ confirmButtonText }}</el-button>
<el-button :class="[ cancelButtonClasses ]" v-show="showCancelButton" @click.native="handleAction('cancel')">{{ cancelButtonText || t('el.messagebox.cancel') }}</el-button>
<el-button ref="confirm" :class="[ confirmButtonClasses ]" v-show="showConfirmButton" @click.native="handleAction('confirm')">{{ confirmButtonText || t('el.messagebox.confirm') }}</el-button>
</div>
</div>
</div>
@ -25,6 +25,7 @@
<script type="text/babel">
import Popup from 'vue-popup';
import Locale from 'element-ui/src/mixins/locale';
import ElInput from 'element-ui/packages/input';
import ElButton from 'element-ui/packages/button';
import { addClass, removeClass } from 'wind-dom/src/class';
@ -38,7 +39,7 @@
};
export default {
mixins: [Popup],
mixins: [Popup, Locale],
props: {
modal: {
@ -173,7 +174,7 @@
data() {
return {
title: '',
title: undefined,
message: '',
type: '',
showInput: false,
@ -184,12 +185,11 @@
inputErrorMessage: '',
showConfirmButton: true,
showCancelButton: false,
confirmButtonText: t('el.messagebox.confirm'),
cancelButtonText: t('el.messagebox.cancel'),
confirmButtonText: '',
cancelButtonText: '',
confirmButtonClass: '',
confirmButtonDisabled: false,
cancelButtonClass: '',
editorErrorMessage: null,
callback: null
};

View File

@ -149,7 +149,9 @@
multiple: Boolean,
placeholder: {
type: String,
default: t('el.select.placeholder')
default() {
return t('el.select.placeholder');
}
}
},

View File

@ -137,7 +137,9 @@
emptyText: {
type: String,
default: t('el.table.emptyText')
default() {
return t('el.table.emptyText');
}
}
},

View File

@ -25,7 +25,9 @@
},
emptyText: {
type: String,
default: t('el.tree.emptyText')
default() {
return t('el.tree.emptyText');
}
},
nodeKey: String,
checkStrictly: Boolean,

View File

@ -63,6 +63,7 @@ export default {
pageClassifier: ''
},
messagebox: {
title: 'Message',
confirm: 'OK',
cancel: 'Cancel',
error: 'Illegal input'

View File

@ -63,6 +63,7 @@ export default {
pageClassifier: '页'
},
messagebox: {
title: '提示',
confirm: '确定',
cancel: '取消',
error: '输入的数据不合法!'