Skip to content

Fix copying translations naming its plural catchall after the source into the editor - #4407

Merged
flodolo merged 4 commits into
mozilla:mainfrom
mathjazz:4398-locale-catchall-on-copy
Aug 18, 2026
Merged

Fix copying translations naming its plural catchall after the source into the editor#4407
flodolo merged 4 commits into
mozilla:mainfrom
mathjazz:4398-locale-catchall-on-copy

Conversation

@mathjazz

@mathjazz mathjazz commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Fix #4398.

Copying a translation into the editor matches its fields against the ones on screen by id, and the id carries the catchall's name. A translation naming its plural catchall after the source, e.g. *[other] where this locale's categories are one/few/many, therefore matched nothing, and the locale's own catchall field stayed empty until a second click.

Reduce the catchall to * in the id instead of using its name. It is the same field either way.

The alternatives would be:

Check out the example string on DEV:
https://pontoon.allizom.org/uk/firefox/all-resources/?string=317622

Same string on PROD:
https://pontoon.mozilla.org/uk/firefox/all-resources/?string=317622

The 1st commit fixes the problem with the input field staying empty after 1st click, and 2nd commit fixes the problem with the right catchall name being used as the label.

Copying a translation into the editor matches its fields against the ones
on screen by id, and the id carries the catchall's name. A translation
naming its plural catchall after the source, e.g. `*[other]` where this
locale's categories are one/few/many, therefore matched nothing, and the
locale's own catchall field stayed empty until a second click.

Reduce the catchall to `*` in the id instead of using its name. It is the
same field either way.
Copying a translation into the editor wrote its values straight into the
field editors from inside the `setState` updater. Each write dispatches an
editor change, whose own state update then arrives during React's render
phase, which defers the update being made to the next render. The values
appeared at once, being written imperatively, but everything React draws
from the new fields — the plural labels above all — was a click behind.

That is the "takes two clicks" the removed HACK comment described, and
what remained visible after the field ids stopped carrying the catchall's
name.

Record the values instead, and write them in an effect once the update is
committed.
@mathjazz
mathjazz requested a review from eemeli August 13, 2026 15:22
@mathjazz mathjazz changed the title 4398 locale catchall on copy Fix copying translations naming its plural catchall after the source into the editor Aug 13, 2026
# Conflicts:
#	translate/src/context/Editor.test.jsx
#	translate/src/context/Editor.tsx

@eemeli eemeli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good; did not test if it performs as intended, trusting you on that.

Comment thread translate/src/context/Editor.tsx Outdated
@flodolo
flodolo requested a review from eemeli August 18, 2026 07:02
@flodolo
flodolo merged commit ed0debd into mozilla:main Aug 18, 2026
10 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.

Restoring suggestion with mismatched plural forms doesn't work the first time

3 participants