aymericzip / aymericzip/intlayer

`intlayer fill` does not re-translate keys whose source value changed

Open
#513 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cli
Dominant language
TypeScript
Stars
833
Forks
126
Avg merge
1d 3h
Merged PRs (30d)
7

Description

Problem

When using intlayer fill to auto-fill all locales, editing the value of an existing key in the source locale has no effect on the other locales: the old translations are kept.

// before
title: t({ en: 'Welcome', fr: 'Bienvenue', es: 'Bienvenido' })

// after editing en and running `npx intlayer fill`
title: t({ en: 'Welcome back', fr: 'Bienvenue', es: 'Bienvenido' }) // fr / es untouched

Nothing in the configuration allows changing this behavior.

Why

fill in its default complete mode has no change detection. It only compares the source-locale content with each target locale and keeps the keys that are missing in the target. A key that already has a value is considered done, whatever the source now says.

Current workarounds

  • Rename the key (it becomes "missing" everywhere and gets re-translated).
  • Delete the stale translations by hand.
  • npx intlayer fill --mode review --key <dictionary-key> — review mode re-translates every key of the dictionary, including the up-to-date ones (cost + risk of unwanted changes on unrelated keys).

What we'd like

fill should detect that the source value of an existing key changed since it was last translated, and re-translate that key (only that key) in the target locales.

Constraints to keep in mind

  • .intlayer/ is git-ignored, so nothing persisted there survives a fresh clone or CI.
  • git may not be installed (or the project may not be a repo), so a git diff-based detection can't be the only mechanism.
  • Detection should work for every content declaration format (.content.ts, .json, .md, per-locale JSON via the sync plugins, …), i.e. ideally on the built dictionaries rather than on the raw files.

Possible directions

  1. Journal / lock file — persist a hash of the source value each translation was made from (e.g. a committed intlayer.journal.json keyed by dictionary key → node path → target locale). On the next fill, a mismatching hash means the key is stale and gets re-translated. First run seeds the file without re-translating anything.
  2. Git-based (when available) — diff the source-locale values of .content.* files against the last commit / a given ref (--git-diff, --base options already exist on some commands) and run fill --mode review --key <changed-keys> on the affected dictionaries. Cheap to build on top of existing flags, but not usable without git.
  3. Content similarity — the doc review command already compares paragraph similarity across languages for docs; the same idea is hard to apply reliably to short UI strings, so probably not the way to go on its own.

A combination is plausible: journal as the source of truth, with a git-based shortcut to select the dictionaries to check.

Related

  • intlayer fill --mode review (re-translates everything)
  • intlayer doc review (similarity-based review for docs)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the intlayer fill command and its complete and review modes; inspect how built dictionaries are produced for .content.ts, .json, .md, and per-locale JSON through sync plugins. Compare the existing doc review similarity flow and any --git-diff/--base handling. Done means changed source values are detected without relying only on git and only affected target keys are re-translated.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, localization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.