2019-02-07 10:43:36 +08:00

11 lines
375 B
TypeScript

import { get, camelize } from '..';
import { lang, messages } from '../../locale';
export default (name: string) => {
const prefix = camelize(name) + '.';
return (path: string, ...args: any[]): string => {
const message = get(messages[lang], prefix + path) || get(messages[lang], path);
return typeof message === 'function' ? message(...args) : message;
};
};