mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 10:44:59 +00:00
[improvement] Remove create & i18 mixin (#2670)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import VantDoc, { DemoBlock, DemoSection } from '@vant/doc';
|
||||
import i18n from '../../packages/mixins/i18n';
|
||||
import i18n from './utils/i18n';
|
||||
import Vant, { Lazyload, Locale } from '../../packages';
|
||||
import { camelize } from '../../packages/utils';
|
||||
|
||||
|
24
docs/src/utils/i18n.js
Normal file
24
docs/src/utils/i18n.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// component mixin
|
||||
import { get, camelize } from '../../../packages/utils';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
$t() {
|
||||
const { name } = this.$options;
|
||||
const prefix = name ? camelize(name) + '.' : '';
|
||||
|
||||
if (!this.$vantMessages) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.error('[Vant] Locale not correctly registered');
|
||||
}
|
||||
return () => '';
|
||||
}
|
||||
|
||||
const messages = this.$vantMessages[this.$vantLang];
|
||||
return (path, ...args) => {
|
||||
const message = get(messages, prefix + path) || get(messages, path);
|
||||
return typeof message === 'function' ? message(...args) : message;
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user