MCPcopy
hub / github.com/youzan/vant / createTranslate

Function createTranslate

packages/vant/src/utils/create.ts:5–14  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

3import locale from '../locale';
4
5export function createTranslate(name: string) {
6 const prefix = camelize(name) + '.';
7
8 return (path: string, ...args: unknown[]) => {
9 const messages = locale.messages();
10 const message = get(messages, prefix + path) || get(messages, path);
11
12 return isFunction(message) ? message(...args) : message;
13 };
14}
15
16export type Translate = ReturnType<typeof createTranslate>;
17

Callers 2

useTranslateFunction · 0.90
createNamespaceFunction · 0.85

Calls 3

camelizeFunction · 0.90
getFunction · 0.90
isFunctionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…