mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
11 lines
377 B
TypeScript
11 lines
377 B
TypeScript
import { get, camelize } from '..';
|
|
import locale from '../../locale';
|
|
|
|
export const useI18N = (name: string) => {
|
|
const prefix = camelize(name) + '.';
|
|
return (path: string, ...args: any[]): string => {
|
|
const message = get(locale.messages(), prefix + path) || get(locale.messages(), path);
|
|
return typeof message === 'function' ? message(...args) : message;
|
|
};
|
|
};
|