MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / promptLocalization

Function promptLocalization

src/cli/init.ts:536–584  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

534}
535
536export async function promptLocalization() {
537 const configureLocalization = await confirm({
538 message: "Configure localization resources?",
539 default: false,
540 });
541
542 if (!configureLocalization) {
543 return undefined;
544 }
545
546 const placeholderRegex = /\$\{locale\}/i;
547
548 const resourcesPath = await input({
549 message:
550 "Localization resources path (must include ${locale} placeholder):",
551 default: "resources/${locale}.json",
552 validate: (value) => {
553 if (!value.trim()) {
554 return "Resources path is required";
555 }
556 if (value.includes("..")) {
557 return "Relative paths cannot include '..'";
558 }
559 if (!placeholderRegex.test(value)) {
560 return "Path must include a ${locale} placeholder";
561 }
562 return true;
563 },
564 });
565
566 const defaultLocale = await input({
567 message: "Default locale (BCP 47, e.g., en-US):",
568 default: "en-US",
569 validate: (value) => {
570 if (!value.trim()) {
571 return "Default locale is required";
572 }
573 if (!/^[A-Za-z0-9]{2,8}(?:-[A-Za-z0-9]{1,8})*$/.test(value)) {
574 return "Default locale must follow BCP 47 (e.g., en-US or zh-Hans)";
575 }
576 return true;
577 },
578 });
579
580 return {
581 resources: resourcesPath,
582 default_locale: defaultLocale,
583 };
584}
585
586export async function promptCompatibility(
587 serverType: "node" | "python" | "binary",

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…