feat(cli): support switch lang

This commit is contained in:
陈嘉涵
2019-12-09 16:24:25 +08:00
parent e461a80dbe
commit cf172f5cbc
7 changed files with 61 additions and 26 deletions

View File

@@ -8,8 +8,9 @@ Vue.mixin({
computed: {
$t() {
const { name } = this.$options;
const { lang } = this.$route.meta || {};
const prefix = name ? camelize(name) + '.' : '';
const messages = this.$vantMessages[this.$vantLang];
const messages = this.$vantMessages[lang];
return (path, ...args) => {
const message = get(messages, prefix + path) || get(messages, path);
@@ -20,6 +21,7 @@ Vue.mixin({
beforeCreate() {
const { i18n, name } = this.$options;
if (i18n) {
const locales = {};
const camelizedName = camelize(name);