-
Notifications
You must be signed in to change notification settings - Fork 0
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.
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:
- Allowlisted keys are ignored.
- Allowlisted values are ignored.
- Same-language-family locale pairs are ignored when
ignoreSameLanguageFamilyis enabled. - Blank values, placeholder-only values, URLs, phone links, and email addresses are ignored.
- Code-like values are ignored when
ignoreCodeLikeis enabled. - Short common labels such as
OKandIDare low severity. - Multi-word Latin text and sentence-like text are high severity.
- Single Latin words are medium severity.
- Everything else is low severity.
This keeps the tool conservative enough for gradual CI adoption while still surfacing likely copied English strings.
check-placeholders extracts placeholders from base and target values with the configured regular expressions.
A target value is:
-
highseverity when it is missing a base placeholder -
mediumseverity 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.
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.
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.