{"record":{"id":"76118b1bea51e822","repo":"clash-verge-rev/clash-verge-rev","slug":"group-label-baseline-locale-options-baseli","errorCode":null,"errorMessage":"[${group.label}] Baseline locale \"${options.baseline}\" not found. Available locales: ${available}","messagePattern":"\\[(.+?)\\] Baseline locale \"(.+?)\" not found\\. Available locales: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/cleanup-unused-i18n.mjs","lineNumber":1279,"sourceCode":"  }\n\n  const sourceFiles = collectSourceFiles(sourceDirs, {\n    supportedExtensions: group.supportedExtensions,\n  })\n  const locales = group.locales\n\n  if (locales.length === 0) {\n    console.log(`[${group.label}] No locale files found.`)\n    return null\n  }\n\n  const baselineLocale = locales.find(\n    (item) => item.name.toLowerCase() === options.baseline.toLowerCase(),\n  )\n\n  if (!baselineLocale) {\n    const available = locales.map((item) => item.name).join(', ')\n    throw new Error(\n      `[${group.label}] Baseline locale \"${options.baseline}\" not found. Available locales: ${available}`,\n    )\n  }\n\n  const baselineData = JSON.parse(JSON.stringify(baselineLocale.data))\n  const baselineEntries = flattenLocale(baselineData)\n  const baselineNamespaces = new Set(Object.keys(baselineData))\n  const usage = collectUsedI18nKeys(sourceFiles, baselineNamespaces)\n  const baselineKeys = new Set(baselineEntries.keys())\n  const missingFromSource = Array.from(usage.usedKeys).filter(\n    (key) => !baselineKeys.has(key),\n  )\n  missingFromSource.sort()\n\n  locales.sort((a, b) => {\n    if (a.name === baselineLocale.name) return -1\n    if (b.name === baselineLocale.name) return 1\n    return a.name.localeCompare(b.name)","sourceCodeStart":1261,"sourceCodeEnd":1297,"githubUrl":"https://github.com/clash-verge-rev/clash-verge-rev/blob/5cad0f2799e74b1105e133bcfc2a45f5c1370ef1/scripts/cleanup-unused-i18n.mjs#L1261-L1297","documentation":"Thrown by processLocaleGroup when the baseline locale specified via --baseline (default 'en') doesn't match any loaded locale file by name (case-insensitive). The error message lists all available locale names so the user can pick a valid one. The baseline locale is the reference for key comparison, alignment, and unused-key detection.","triggerScenarios":"Running with --baseline fr when only 'en', 'zh-CN', 'ja' locale files exist. Running with --baseline english when the file is named en.json. The match is case-insensitive on the file name (without extension).","commonSituations":"Specifying a locale code that doesn't match any file name. Locale files named differently than expected (e.g., 'en-US.json' vs 'en.json'). Repository without the default 'en' locale. Typographical errors in the --baseline value.","solutions":["Check available locale files: ls src/locales/ and use one of those names","Use the correct locale code matching the file name without extension","Omit --baseline to use the default 'en' if an en locale exists","Create the baseline locale file if it should exist"],"exampleFix":"// before\nnode scripts/cleanup-unused-i18n.mjs --baseline french\n// after (check available first)\nls src/locales/  # shows: en.json zh-CN.json ja.json\nnode scripts/cleanup-unused-i18n.mjs --baseline en","handlingStrategy":"validation","validationCode":"import fs from 'fs'\nimport path from 'path'\n\nfunction getAvailableLocales(localesDir: string): string[] {\n  if (!fs.existsSync(localesDir)) return []\n  return fs.readdirSync(localesDir, { withFileTypes: true })\n    .filter(e => e.isFile() && e.name.endsWith('.json') && !e.name.endsWith('.bak'))\n    .map(e => e.name.replace(/\\.json$/i, ''))\n}\n\nfunction isBaselineAvailable(localesDir: string, baseline: string): boolean {\n  const available = getAvailableLocales(localesDir).map(l => l.toLowerCase())\n  return available.includes(baseline.toLowerCase())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List available locales before specifying --baseline: ls src/locales/","Use the file name without extension as the locale code (e.g., 'en' for en.json)","If the default 'en' doesn't exist, create it or specify the correct baseline"],"tags":["i18n","locales","baseline","configuration","script"],"analyzedSha":"5cad0f2799e74b1105e133bcfc2a45f5c1370ef1","analyzedAt":"2026-08-12T03:25:57.699Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}