clash-verge-rev/clash-verge-rev · error · Error

[${group.label}] Baseline locale "${options.baseline}" not f

Error message

[${group.label}] Baseline locale "${options.baseline}" not found. Available locales: ${available}

What it means

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.

Source

Thrown at scripts/cleanup-unused-i18n.mjs:1279

  }

  const sourceFiles = collectSourceFiles(sourceDirs, {
    supportedExtensions: group.supportedExtensions,
  })
  const locales = group.locales

  if (locales.length === 0) {
    console.log(`[${group.label}] No locale files found.`)
    return null
  }

  const baselineLocale = locales.find(
    (item) => item.name.toLowerCase() === options.baseline.toLowerCase(),
  )

  if (!baselineLocale) {
    const available = locales.map((item) => item.name).join(', ')
    throw new Error(
      `[${group.label}] Baseline locale "${options.baseline}" not found. Available locales: ${available}`,
    )
  }

  const baselineData = JSON.parse(JSON.stringify(baselineLocale.data))
  const baselineEntries = flattenLocale(baselineData)
  const baselineNamespaces = new Set(Object.keys(baselineData))
  const usage = collectUsedI18nKeys(sourceFiles, baselineNamespaces)
  const baselineKeys = new Set(baselineEntries.keys())
  const missingFromSource = Array.from(usage.usedKeys).filter(
    (key) => !baselineKeys.has(key),
  )
  missingFromSource.sort()

  locales.sort((a, b) => {
    if (a.name === baselineLocale.name) return -1
    if (b.name === baselineLocale.name) return 1
    return a.name.localeCompare(b.name)

View on GitHub (pinned to 5cad0f2799)

Solutions

  1. Check available locale files: ls src/locales/ and use one of those names
  2. Use the correct locale code matching the file name without extension
  3. Omit --baseline to use the default 'en' if an en locale exists
  4. Create the baseline locale file if it should exist

Example fix

// before
node scripts/cleanup-unused-i18n.mjs --baseline french
// after (check available first)
ls src/locales/  # shows: en.json zh-CN.json ja.json
node scripts/cleanup-unused-i18n.mjs --baseline en
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs'
import path from 'path'

function getAvailableLocales(localesDir: string): string[] {
  if (!fs.existsSync(localesDir)) return []
  return fs.readdirSync(localesDir, { withFileTypes: true })
    .filter(e => e.isFile() && e.name.endsWith('.json') && !e.name.endsWith('.bak'))
    .map(e => e.name.replace(/\.json$/i, ''))
}

function isBaselineAvailable(localesDir: string, baseline: string): boolean {
  const available = getAvailableLocales(localesDir).map(l => l.toLowerCase())
  return available.includes(baseline.toLowerCase())
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of clash-verge-rev/clash-verge-rev@5cad0f2799 (2026-08-12). Data as JSON: /api/errors/76118b1bea51e822. Report an issue: GitHub.