MCPcopy
hub / github.com/AsyncFuncAI/deepwiki-open / t

Function t

src/app/page.tsx:51–76  ·  view source on GitHub ↗
(key: string, params: Record<string, string | number> = {})

Source from the content-addressed store, hash-verified

49
50 // Create a simple translation function
51 const t = (key: string, params: Record<string, string | number> = {}): string => {
52 // Split the key by dots to access nested properties
53 const keys = key.split('.');
54 // eslint-disable-next-line @typescript-eslint/no-explicit-any
55 let value: any = messages;
56
57 // Navigate through the nested properties
58 for (const k of keys) {
59 if (value && typeof value === 'object' && k in value) {
60 value = value[k];
61 } else {
62 // Return the key if the translation is not found
63 return key;
64 }
65 }
66
67 // If the value is a string, replace parameters
68 if (typeof value === 'string') {
69 return Object.entries(params).reduce((acc: string, [paramKey, paramValue]) => {
70 return acc.replace(`{${paramKey}}`, String(paramValue));
71 }, value);
72 }
73
74 // Return the key if the value is not a string
75 return key;
76 };
77
78 const [repositoryInput, setRepositoryInput] = useState('https://github.com/AsyncFuncAI/deepwiki-open');
79

Callers 1

HomeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected