Internationalization (i18n)¶
The i18n package defines semantic types for internationalization and
localization findings and projects them into the domain-neutral
Finding.
Issue¶
Issue is an internationalization finding.
| Field | Type | Notes |
|---|---|---|
ID |
string |
Stable identifier |
Title |
string |
Short human-readable summary |
Description |
string |
Detailed explanation |
Kind |
Kind |
Category of the issue |
Key |
string |
Affected message key, when applicable |
Locale |
string |
Affected locale (BCP 47), when applicable |
Severity |
findingspec.Severity |
Impact; defaults to Medium when unset |
Location |
*findingspec.Location |
Where it was observed — see Location |
Remediation |
*findingspec.Remediation |
How to fix, incl. an AgentPrompt |
Status |
findingspec.Status |
Lifecycle state |
DetectedAt |
*time.Time |
When observed |
Kind¶
Kind categorizes an internationalization issue.
| Constant | Value | Meaning |
|---|---|---|
KindMissingTranslation |
missing_translation |
A message key with no translation for a locale |
KindHardcodedString |
hardcoded_string |
User-facing text that is not externalized for translation |
KindInvalidPlaceholder |
invalid_placeholder |
A translation whose placeholders do not match the source string |
KindUntranslatedFormat |
untranslated_format |
A locale-specific formatting problem (dates, numbers, currency, pluralization) |
Projection to Finding¶
ToFinding() projects the issue into a domain-neutral findingspec.Finding in
the i18n domain:
- sets
Domaintofindingspec.DomainI18n; - sets
RuleIDto theKindvalue; - defaults
Severitytofindingspec.SeverityMediumwhen unset, on the shared severity scale; - adds a
locale:<locale>tag for a non-emptyLocale.
issue := i18n.Issue{
ID: "i18n-001",
Title: "Missing translation for checkout button",
Kind: i18n.KindMissingTranslation,
Key: "checkout.button.label",
Locale: "fr-FR",
Location: &findingspec.Location{
File: "locales/fr-FR/messages.json",
},
}
f := issue.ToFinding()
f.Domain // "i18n"
f.RuleID // "missing_translation"
f.Severity // "medium" (defaulted)
f.Tags // ["locale:fr-FR"]