Skip to content

Configuration

Yuki edited this page Jul 13, 2026 · 3 revisions

Configuration

The CLI reads a config file named i18n-smell.config.mjs by default. It also supports .js, .cjs, and .json.

Minimal Config

export default {
  baseLocale: 'en',
  locales: {
    en: './src/locales/en.json',
    zh: './src/locales/zh.json',
    'zh-Hans': './src/locales/zh-Hans.json'
  },
  source: [
    'src/**/*.{vue,js,jsx,ts,tsx}'
  ]
};

Full Example

export default {
  preset: 'recommended',
  baseLocale: 'en',
  checks: {
    identical: true,
    hardcoded: true,
    placeholders: true
  },
  locales: {
    en: './src/locales/en.json',
    zh: './src/locales/zh.json',
    'zh-Hans': './src/locales/zh-Hans.json',
    ja: './src/locales/ja.json'
  },
  source: [
    'src/**/*.{vue,js,jsx,ts,tsx}'
  ],
  allowIdenticalKeys: [
    'brand.*',
    /^protocol\./
  ],
  allowIdenticalValues: [
    'OK',
    'ID',
    'API'
  ],
  doNotTranslate: [
    {
      values: ['PRODUCT_X', /^MODEL-\d+$/],
      category: 'product-name',
      reason: 'Official product terminology',
      owner: 'localization-team'
    }
  ],
  placeholderPatterns: [
    '\\{\\{[^}]+\\}\\}',
    '(?<!\\{)\\{[^{}]+\\}(?!\\})',
    '%[sdif]',
    '%\\([^)]+\\)[sdif]'
  ],
  hardcoded: {
    vueAttributes: ['placeholder', 'title', 'alt', 'aria-label', 'aria-description'],
    jsxAttributes: ['placeholder', 'title', 'alt', 'aria-label', 'aria-description'],
    functions: ['toast.success', 'toast.error', 'alert', 'confirm'],
    ignoreFiles: ['src/generated/**'],
    ignoreValues: ['OK', 'ID'],
    ignorePatterns: ['^v\\d+$'],
    technicalTerms: ['PROTOCOL_X', /^MODEL-\d+$/],
    sinks: {
      calls: [{ callee: 'notify', arguments: [0] }],
      assignments: ['error.value'],
      properties: ['summary', 'detail']
    }
  },
  ignoreCodeLike: true,
  ignoreSameLanguageFamily: true,
  trimWhitespace: true,
  ignoreCase: false,
  includeIgnored: false,
  format: 'console',
  baseline: '.i18n-smell-baseline.json',
  failOn: 'high'
};

Important Options

Option Purpose
baseLocale Locale used as the source language.
preset Optional preset. Use recommended for defaults or strict for stricter CI.
locales Map of locale code to JSON locale file.
source Files scanned by check-hardcoded.
checks Enables checks for the combined check command.
allowIdenticalKeys Allows copied values for matching locale keys.
allowIdenticalValues Allows copied values for exact values or regex matches.
doNotTranslate Categorized, auditable identical-value suppressions.
placeholderPatterns Defines placeholder tokens used by locale checks.
hardcoded.vueAttributes Vue static attributes to scan.
hardcoded.jsxAttributes JSX/TSX static attributes to scan.
hardcoded.functions JS/TS function calls whose static string arguments are scanned.
hardcoded.sinks Precise call arguments, assignment targets, and object properties to scan recursively.
hardcoded.technicalTerms Project-specific technical values that should receive low confidence.
hardcoded.ignoreFiles Source files excluded from hardcoded scanning.
failOn Lowest severity that exits with code 1.

Locale keys that contain -, such as 'zh-Hans', must be quoted in JavaScript config files.

Dollar-number placeholders such as $1 are opt-in. Add '\\$\\d+' to placeholderPatterns only when the project uses that syntax and the values cannot be confused with currency.

Presets

preset: 'recommended' keeps the default behavior.

preset: 'strict' is useful once a project has already tuned allowlists and baselines. It currently:

  • sets failOn to medium
  • sets ignoreSameLanguageFamily to false

Explicit options in your config win over preset defaults.

Path Resolution

locales, source, baseline, and output paths are resolved relative to the config file location when applicable.

Clone this wiki locally