Skip to content

feat: ignore keys only for selected target locales (1.9.0) - #83

Merged
Starllordz merged 2 commits into
mainfrom
feature/key-ignore-for-language
Nov 13, 2026
Merged

Starllordz merged 2 commits into
mainfrom
feature/key-ignore-for-language

Conversation

@Starllordz

@Starllordz Starllordz commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

ignoredKeys applied to every target locale, so there was no way to ignore a key for only some languages. Entries can now be an object that lists the target locales it applies to:

ignoredKeys:
  - "internal/**"            # every target locale (unchanged)
  - path: "legal/**"
    locales: [de-DE, fr-FR]  # only these target locales

For the listed locales the key behaves exactly like an ignored key today: an existing target value is preserved as-is, a missing one is not added. Other locales translate it normally.

Changes

  • Schema (src/modules/config/config.types.ts): ignoredKeys accepts a key pattern or { path, locales }, with locales a non-empty list of valid locales. A locale not in locales.target is a config error pointing at the entry, e.g.
    files.json.ignoredKeys.1.locales: Locale "de" is not a target locale (add it to locales.target or remove it from this rule).
    This catches typos like de vs de-DE, which would otherwise silently translate the key. Entries are not transformed while parsing, so memory/glossary commands that rewrite lara.yaml keep the user's syntax.
  • Engine (src/modules/translation/translation.engine.ts): isIgnored() takes the target locale being processed. The per-locale loop already existed.
  • Docs: new "Per-Language Ignored Keys" section in docs/config/files.md, example in docs/config/structure.md.
  • Version: 1.9.0 in package.json and the README badge (the badge was still at 1.7.3).
  • Separate commit: Prettier on glossary.ts, memory.ts, error.ts, which already failed format:check on main. Formatting only, no logic changes.

Tests

  • Schema: string, object and mixed forms; rejection of empty locales, missing fields, unknown codes, non-target and source locales, with the exact issue path.

  • Config round-trip: addIdToConfig keeps the { path, locales } form.

  • All 10 formats: a 3-phase scenario with several targets.

    1. it + fr, no rule: both get every key.
    2. Ignore for fr only and change the source: it is re-translated, fr keeps its old value.
    3. Add de, ignored too: de never receives the key.

    For single-file formats (i18n.ts, Vue, .xcstrings) it also checks the source string survives.

  • JSON edge cases: mixed global and per-locale rules, no API call for ignored locales, key deleted from source (removed in it, kept in fr), includeKeys, --target, invalid config.

  • Mutation check: making the rule apply to all locales, or to none, fails 15 tests each; removing the locale validation fails 4.

pnpm test (1032 tests), build, lint and format:check are clean.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

ignoredKeys entries can now be an object { path, locales } to ignore a key
only for the listed target locales. Plain string entries keep applying to
every target locale, and both forms can be mixed.

- Schema: union of KeyPath and { path, locales }; a locale not in
  locales.target is a config error (catches typos such as de vs de-DE).
  Entries are not transformed, so commands that rewrite lara.yaml keep the
  user's syntax.
- Engine: isIgnored() takes the target locale being processed.
- Tests: schema tests, config round-trip, a 3-phase multi-locale scenario
  for all 10 formats, and JSON edge cases (mixed rules, source deletion,
  includeKeys, --target, invalid config).
- Docs: per-language ignored keys section in docs/config/files.md.
- Version bumped to 1.9.0 (package.json and README badge).
@Starllordz
Starllordz requested a review from Khalester November 13, 2026 09:56
@Starllordz
Starllordz merged commit 8008d58 into main Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants