[improvement] organize type definitions

This commit is contained in:
陈嘉涵
2019-05-13 19:07:04 +08:00
parent 96b1d8f81d
commit 7755b1738e
40 changed files with 111 additions and 121 deletions
+4 -3
View File
@@ -1,10 +1,11 @@
import { get, camelize } from '..';
import locale from '../../locale';
export const useI18N = (name: string) => {
export function useI18N(name: string) {
const prefix = camelize(name) + '.';
return (path: string, ...args: any[]): string => {
return function (path: string, ...args: any[]): string {
const message = get(locale.messages(), prefix + path) || get(locale.messages(), path);
return typeof message === 'function' ? message(...args) : message;
};
};
}