Skip to content

Algorithms

Yuki edited this page Jul 10, 2026 · 1 revision

Algorithms

i18n-smell-detector is deliberately heuristic. It does not claim to know whether a translation is linguistically correct. It identifies values that deserve human review.

Identical Translation Classification

check-identical compares each target locale value against the configured base locale after optional whitespace trimming and case normalization.

The classifier applies rules in this order:

  1. Allowlisted keys are ignored.
  2. Allowlisted values are ignored.
  3. Same-language-family locale pairs are ignored when ignoreSameLanguageFamily is enabled.
  4. Blank values, placeholder-only values, URLs, phone links, and email addresses are ignored.
  5. Code-like values are ignored when ignoreCodeLike is enabled.
  6. Short common labels such as OK and ID are low severity.
  7. Multi-word Latin text and sentence-like text are high severity.
  8. Single Latin words are medium severity.
  9. Everything else is low severity.

This keeps the tool conservative enough for gradual CI adoption while still surfacing likely copied English strings.

Placeholder Classification

check-placeholders extracts placeholders from base and target values with the configured regular expressions.

A target value is:

  • high severity when it is missing a base placeholder
  • medium severity when it has extra placeholders only

Default placeholder patterns cover common brace, mustache, printf, named printf, and $1 styles.

ICU and MessageFormat parsing should be implemented as parser-backed rules rather than another broad regular expression.

Hardcoded String Classification

check-hardcoded scans Vue templates, Vue script blocks, JavaScript, TypeScript, JSX, and TSX.

It reports:

  • static text nodes
  • selected static attributes
  • configured function-call arguments

It ignores values that are likely not user-facing:

  • whitespace and punctuation-only strings
  • colors
  • URLs, mail, and phone links
  • paths and asset names
  • short all-caps protocol or code values

Visible sentence-like content is high severity, single words are medium, and short common labels are low.

Extension Direction

Machine-learning or language-specific classifiers should plug in behind the same classification shape:

type ClassificationResult = {
  severity: 'ignored' | 'low' | 'medium' | 'high';
  reason: string;
};

The built-in classifiers stay deterministic so CI output remains stable.

Clone this wiki locally