Lint rules
invalid-locale
errorFlags a messages file whose locale the runtime doesn't recognize.
Why this is bad
The Intl APIs resolve an unknown tag to the runtime's default rather than rejecting it, so plural rules, number formats, and dates all quietly come out as the default locale's.
Examples
The locale comes from the filename, so a name the runtime can't parse is incorrect.
Examples of incorrect code for this rule:
messages/
spanish.json
Examples of correct code for this rule:
messages/
es.json
False positives
If your file names intentionally differ from your locales, list the real tags in messages.locales and map each one to its file via messages.codes with the {code} placeholder.
This way, you can read messages e.g. from ./messages/spanish.json, while lint and translation use the expected locale es.
How to fix it
There are two ways to fix this:
- Rename the file to a valid locale, e.g.
spanish.jsontoes.json. - If your file names intentionally differ from your locales, map each locale to its file name via
messages.codesand use the{code}placeholder inmessages.path.