MCPcopy
hub / github.com/YouMind-OpenLab/awesome-gpt-image-2 / t

Function t

scripts/utils/i18n.ts:1372–1394  ·  view source on GitHub ↗
(key: keyof Translation, locale: string, params?: Record<string, string>)

Source from the content-addressed store, hash-verified

1370};
1371
1372export function t(key: keyof Translation, locale: string, params?: Record<string, string>): string {
1373 let text: string;
1374
1375 // Try specific locale match first
1376 if (I18N[locale] && I18N[locale][key]) {
1377 text = I18N[locale][key];
1378 } else if (locale === 'es-419') {
1379 // Fallback logic
1380 text = I18N['es-ES'][key] || en[key];
1381 } else if (locale === 'pt-PT') {
1382 text = I18N['pt-BR'][key] || en[key];
1383 } else {
1384 // Default fallback to English
1385 text = en[key] || key;
1386 }
1387
1388 // Replace {{xx}} placeholders with params
1389 if (params) {
1390 text = text.replace(/\{\{(\w+)\}\}/g, (_, key) => params[key] ?? `{{${key}}}`);
1391 }
1392
1393 return text;
1394}
1395

Callers 11

generateHeaderFunction · 0.85
generateGalleryCTAFunction · 0.85
generatePromptSectionFunction · 0.85
generateFeaturedSectionFunction · 0.85
generateStatsFunction · 0.85
generateTOCFunction · 0.85
generateWhatIsFunction · 0.85
generateContributeFunction · 0.85
generateFooterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected