[improvement] organize type definitions
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user