[improvement] use i18n (#2454)

This commit is contained in:
neverland
2019-01-07 15:24:34 +08:00
committed by GitHub
parent ed7febc131
commit c6e1aaf5da
4 changed files with 23 additions and 6 deletions
+10
View File
@@ -0,0 +1,10 @@
import { get, camelize } from '..';
import { lang, messages } from '../../locale';
export default name => {
const prefix = camelize(name) + '.';
return (path, ...args) => {
const message = get(messages[lang], prefix + path) || get(messages[lang], path);
return typeof message === 'function' ? message(...args) : message;
};
};
+2 -1
View File
@@ -1,7 +1,8 @@
import useBem from './bem';
import useSfc from './sfc';
import useI18n from './i18n';
export default function (name) {
name = 'van-' + name;
return [useSfc(name), useBem(name)];
return [useSfc(name), useBem(name), useI18n(name)];
}