[improvement] Remove create & i18 mixin (#2670)

This commit is contained in:
neverland
2019-02-02 10:08:21 +08:00
committed by GitHub
parent ed8a294fe2
commit 89c80e818c
4 changed files with 2 additions and 38 deletions

24
docs/src/utils/i18n.js Normal file
View 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;
};
}
}
};