Skip to content

Fix duplicate react-intl message ids breaking yarn build-locales - #7283

Open
jaroslav-kubicek wants to merge 4 commits into
hotosm:developfrom
jaroslav-kubicek:fix/duplicate-message-ids-build-locales
Open

Fix duplicate react-intl message ids breaking yarn build-locales#7283
jaroslav-kubicek wants to merge 4 commits into
hotosm:developfrom
jaroslav-kubicek:fix/duplicate-message-ids-build-locales

Conversation

@jaroslav-kubicek

@jaroslav-kubicek jaroslav-kubicek commented Jul 2, 2026

Copy link
Copy Markdown

Closes #7284

What

yarn build-locales fails on develop with Error: Duplicate message id: management.button.cancel, so frontend/src/locales/en.json could not be regenerated since June 2025 — no string added since then has reached Transifex. The reported id is only the first duplicate the tool hits; a full audit found 11 duplicated ids. This PR deduplicates all of them, regenerates en.json, and adds a CI step so this class of breakage fails PRs in the future.

Changes

Identical duplicates (translations preserved). levels/messages.js and badges/messages.js re-declared nine ids that teamsAndOrgs/messages.js has defined since 2019 (management.button.cancel, .save, management.fields.name, .description, .managers.add, .organisation.image, management.link.manage, management.badges, management.levels). They now import and re-export the canonical definitions — same runtime keys, zero component changes, existing Transifex ids and translations untouched.

Conflicting duplicates (new ids, no translation loss). Two clusters shared an id with different English texts, so one text silently won depending on extraction order:

  • projectEdit/messages.js vs projectCreate/messages.js: management.projects.create.review.database + .osm + .sandbox ("Database"/"OSM"/"Sandbox" vs "Where should edits be saved?"/"OpenStreetMap (Live)"/"Training Sandbox (Practice)"). The projectEdit entries now use management.projects.edit.database*.
  • taskSelection/messages.js vs projectDetail/messages.js: project.detail.sandbox ("Sandbox(Practice)" vs "Sandbox Mode"). The taskSelection entry now uses project.detail.sandbox.info.

All four renamed ids were added after the last successful en.json regeneration, so they never reached Transifex — no translations are lost. The unused sandbox message in header/messages.js (dead since #7278 moved the badge to the project detail header) is removed.

Regenerated en.json. ~140 additions are a year of accumulated new messages; the few removals/rewordings all correspond to messages actually deleted or changed in source since June 2025. After merge, a maintainer needs to run tx push -s so these strings finally reach translators.

CI guard. pr_test_frontend.yml now runs yarn build-locales after install; the tool exits non-zero on any duplicate id, so future duplicates fail the PR instead of breaking locale regeneration unnoticed. (The contributing guidelines already require regenerating en.json with string changes — this was just unenforced.)

jaroslav-kubicek and others added 3 commits July 2, 2026 15:37
combine-react-intl-messages throws on any message id defined in more
than one src/**/messages.js file, which broke yarn build-locales on
develop (first hit: management.button.cancel). Deduplicate all 11 ids:

- levels/messages.js and badges/messages.js re-export the messages
  they shared with teamsAndOrgs/messages.js (cancel, save, name,
  manage, badges, levels, add, description, image) instead of
  re-declaring them, keeping the existing Transifex ids intact.
- projectEdit database labels get their own management.projects.edit.*
  ids; they collided with projectCreate ids while carrying different
  English texts, and were added after en.json was last regenerated so
  no translations exist for them yet.
- taskSelection sandbox info box gets project.detail.sandbox.info,
  resolving the conflict with projectDetail's project.detail.sandbox
  ("Sandbox Mode" vs "Sandbox(Practice)").
- header/messages.js drops its unused sandbox message, dead since the
  badge moved to the project detail header.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Output of yarn build-locales, which was blocked by the duplicate ids
since mid-2025; the last regeneration was in June 2025, so this picks
up a year of accumulated message additions, rewordings and removals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The tool exits non-zero on any duplicate react-intl message id, so
this makes duplicates fail the PR instead of silently breaking locale
regeneration, which nothing in CI previously exercised.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@sumitdahal7

Copy link
Copy Markdown
Collaborator

Nice fix for the yarn build-locales failure reusing the canonical descriptors, renaming the conflicts, and regenerating the catalog all makes sense.

Two things before I approve:

  1. CI still won't catch a stale catalog, it only fails if generation errors, not if someone forgets to commit the regenerated en.json. Mind adding a diff check after the build step?
yarn build-locales
git diff --exit-code -- src/locales/en.json
  1. Minor: Description says 11 duplicate IDs, but the list adds up to 13. Not blocking, just fix if you get a chance.

Also, no issue at all with using AI to help write this, that's normal. Just noticed a couple commits have a Claude co-author trailer; could you drop that? Just want authorship on the repo to stay clean regardless of what tools were used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] "yarn build-locales" fails on develop: duplicate react-intl message ids

2 participants