mirror of https://github.com/ElemeFE/element
Merge pull request #865 from QingWei-Li/fix/locale-fallback
Locale: fallback default configpull/873/head
commit
1c47153e1a
2
.babelrc
2
.babelrc
|
@ -7,7 +7,7 @@
|
||||||
["module-resolver", {
|
["module-resolver", {
|
||||||
"root": ["element-ui"],
|
"root": ["element-ui"],
|
||||||
"alias": {
|
"alias": {
|
||||||
"element-ui/src/locale": "element-ui/lib/locale"
|
"element-ui/src": "element-ui/lib"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,6 +36,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
version: '{{version}}',
|
version: '{{version}}',
|
||||||
|
locale,
|
||||||
install,
|
install,
|
||||||
{{list}}
|
{{list}}
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async-validator": "^1.6.6",
|
"async-validator": "^1.6.6",
|
||||||
|
"deepmerge": "^1.2.0",
|
||||||
"throttle-debounce": "^1.0.1",
|
"throttle-debounce": "^1.0.1",
|
||||||
"vue-popup": "^0.2.9",
|
"vue-popup": "^0.2.9",
|
||||||
"wind-dom": "0.0.3"
|
"wind-dom": "0.0.3"
|
||||||
|
|
|
@ -131,6 +131,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
version: '1.0.0-rc.8',
|
version: '1.0.0-rc.8',
|
||||||
|
locale,
|
||||||
install,
|
install,
|
||||||
Pagination,
|
Pagination,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
import defaultLang from 'element-ui/src/locale/lang/zh-cn';
|
import defaultLang from 'element-ui/src/locale/lang/zh-cn';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
import deepmerge from 'deepmerge';
|
||||||
import Format from './format';
|
import Format from './format';
|
||||||
|
|
||||||
const format = Format(Vue);
|
const format = Format(Vue);
|
||||||
let lang = defaultLang;
|
let lang = defaultLang;
|
||||||
|
let merged = false;
|
||||||
|
|
||||||
export const $t = function(path, options) {
|
export const $t = function(path, options) {
|
||||||
const vuei18n = Object.getPrototypeOf(this || Vue).$t;
|
const vuei18n = Object.getPrototypeOf(this || Vue).$t;
|
||||||
if (typeof vuei18n === 'function') {
|
if (typeof vuei18n === 'function') {
|
||||||
|
if (!merged) {
|
||||||
|
merged = true;
|
||||||
|
Vue.locale(Vue.config.lang, deepmerge(lang, Vue.locale(Vue.config.lang), { clone: true }));
|
||||||
|
}
|
||||||
return vuei18n.apply(this, [path, options]);
|
return vuei18n.apply(this, [path, options]);
|
||||||
}
|
}
|
||||||
const array = path.split('.');
|
const array = path.split('.');
|
||||||
|
|
Loading…
Reference in New Issue