Repository navigation
Commit dca4bde
authored
Translate the pull request destination and GitHub sign-in (#643)
## Why
The Open a pull request card, its GitHub sign-in, and the errors main
sends it were plain English in a translated window. This is the #625
batch of #622, which needed the catalog in main from #634.
## What changes
- **The card** (`pull-request-destination.jsx`) wraps every string.
Sentences with a link or code in them use `createInterpolateElement`,
with logins, branches and repository names passed in as elements so they
are never read as markup. The failure messages are a function instead of
a module-level constant.
- **Per-project text** in `project-type.cjs` (`cards.*`) is getters,
read when the card renders. Main's refusal with nothing linked used to
splice the work item's label into a sentence; it is now
`cards.prNeedsWorkItem`, one sentence per project type.
- **Main process:** the sign-in errors in `github-auth.cjs` and the pull
request errors in `github-pr.cjs` are wrapped, including the step labels
passed to `failure()`, which the issue did not list. The "Trunk has
moved" message uses `_n`, and a GitHub failure is composed with `%1$s:
%2$s%3$s` so a translator can change the punctuation. GitHub's own
reason and the bracketed diagnostic for GitHub support stay as they are.
Not wrapped, per #622: the pull request body and the default pull
request title, because they leave the app.
## How to test this
The new journeys cover the card in the pseudo-locale on both projects.
Run them from the repository root on either platform:
```
npx playwright test --project=journeys tests/e2e/journeys/i18n.spec.js -g "pull request card"
```
Both fail without this change. The Core journey walks every state #625
lists: signed out, "Not now" and "Show this again", the device code,
signed in with the form and its fold, a `rate-limited` failure, a dry
run, and a pull request opened from a checkout behind trunk. The
Gutenberg one walks signed out, signed in with the fold open, and the
opened pull request, checking the words that are Gutenberg's own.
What the journeys cannot reach is a real GitHub. They stub every
`github:*` handler, so the main-process errors never reach the screen in
them. Unit tests in `github-auth`, `github-pr` and `pr-stage` cover
those strings in the pseudo-locale instead. To see one on screen by hand
(either platform, current head):
1. From the repository root, run `npx electron . --lang=en-XA`.
2. Open a Core site with a linked ticket and an edit, and click **Review
& submit changes**.
3. In **Open a pull request**, click **Sign in with GitHub** and finish
in the browser.
- Expected: every line of the card is accented and in brackets, apart
from your login, your fork's name, the code and the branch.
**What must not have happened:** no English an English speaker sees has
changed. The English journeys in `open-pull-request.spec.js`,
`review-changes.spec.js` and `pr-checkout.spec.js` still pass with their
exact strings.
## Risks and limitations
- The other open batches (#636, #644, #645, #646) also append tests to
the end of `i18n.spec.js`, so whichever merges later resolves that by
keeping both.
- One finding is deferred: `prFailureMessage` decides between five
user-facing strings inside a `.jsx` file the suite cannot load. It
predates this PR (it was the old constant map), so moving it to a `.cjs`
module with a test is a follow-up.
## Related
Fixes #625. Part of #622. Follows #634.
---
<details>
<summary>Design decisions and alternatives considered</summary>
- **Not stacked on #635.** #622 asks for batches that review on their
own. Now that #635 has merged, its `unwrapped()` scanner change and the
`@wordpress/element` dependency, which this PR also needed, come from
trunk.
- **The textarea placeholder** is three strings joined with a newline. A
single `__()` with `\n` in it is refused by
`@wordpress/i18n-no-collapsible-whitespace`.
- **"Signed in as …"** is wrapped in its own `<span>`, so the sentence
and the **Sign out** button beside it are separate elements, as in #635.
</details>
<details>
<summary>Review outcome (required — see AGENTS.md)</summary>
2 [fix here] · 1 [follow-up]. Both [fix here] findings are fixed; the
follow-up is deferred (see Risks).
- 🟡 The Gutenberg journey linked no issue, so it never showed the form,
the fold or the loop-back. Fixed: it links one in the record and walks
those states.
- 🔵 No test showed the main-process strings or the stage labels come out
translated. Fixed: pseudo-locale unit tests for the scope refusal, a
composed `failure()`, the plural stale message and `prStageLabel`.
- Style: three dead entries in the journey's `THEIRS` filter were
removed.
- **Review:** completed. Fresh agent context, head `11ef362` / base
`c34aa45`. `npm run lint` clean, `npm test` 2002 pass / 0 fail, i18n and
PR journeys 25 pass.
- **Since review:** `11ef362 → ef457fd`. The only change is the test
fixes above, checked by the authoring session, not re-reviewed by a
fresh context. `src` and `tests` lint clean, unit suite 2005 pass / 0
fail, i18n journeys 12 pass. The review did not run the journeys itself;
it was read-only.
- **After #635 merged:** `ef457fd → 9559a1f` (trunk merged from GitHub)
→ `012fca8` (trunk at `e94f507` merged; `i18n.spec.js` resolved as
trunk's file plus this PR's two tests, nothing else changed). Checked by
the authoring session, not re-reviewed: `src` and `tests` lint clean,
unit suite 2036 pass / 0 fail, i18n, open-pull-request, review-changes
and pr-checkout journeys 31 pass.
</details>
<details>
<summary>Screenshots or recording</summary>
None. Nothing changes on screen in English, and the pseudo-locale
journeys are the check for the translated state.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent e94f507 commit dca4bde
12 files changed
Lines changed: 447 additions & 112 deletions
File tree
- src
- renderer
- components
- hooks
- tests
- e2e/journeys
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
166 | | - | |
| 169 | + | |
167 | 170 | | |
168 | | - | |
| 171 | + | |
169 | 172 | | |
170 | 173 | | |
171 | 174 | | |
172 | | - | |
| 175 | + | |
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
| |||
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
201 | | - | |
| 204 | + | |
202 | 205 | | |
203 | | - | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
208 | | - | |
| 211 | + | |
| 212 | + | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
| |||
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
255 | | - | |
| 259 | + | |
256 | 260 | | |
257 | 261 | | |
258 | | - | |
| 262 | + | |
| 263 | + | |
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
| |||
265 | 270 | | |
266 | 271 | | |
267 | 272 | | |
268 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
269 | 279 | | |
270 | 280 | | |
271 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
163 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
164 | 179 | | |
165 | 180 | | |
166 | 181 | | |
| |||
276 | 291 | | |
277 | 292 | | |
278 | 293 | | |
279 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
280 | 300 | | |
281 | 301 | | |
282 | 302 | | |
| |||
295 | 315 | | |
296 | 316 | | |
297 | 317 | | |
298 | | - | |
| 318 | + | |
299 | 319 | | |
300 | 320 | | |
301 | 321 | | |
| |||
305 | 325 | | |
306 | 326 | | |
307 | 327 | | |
308 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
309 | 333 | | |
310 | 334 | | |
311 | 335 | | |
| |||
319 | 343 | | |
320 | 344 | | |
321 | 345 | | |
322 | | - | |
| 346 | + | |
323 | 347 | | |
324 | 348 | | |
325 | 349 | | |
| |||
329 | 353 | | |
330 | 354 | | |
331 | 355 | | |
332 | | - | |
| 356 | + | |
333 | 357 | | |
334 | 358 | | |
335 | 359 | | |
| |||
374 | 398 | | |
375 | 399 | | |
376 | 400 | | |
377 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
378 | 406 | | |
379 | 407 | | |
380 | 408 | | |
| |||
475 | 503 | | |
476 | 504 | | |
477 | 505 | | |
478 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
479 | 511 | | |
480 | 512 | | |
481 | 513 | | |
482 | 514 | | |
483 | 515 | | |
484 | | - | |
| 516 | + | |
485 | 517 | | |
486 | 518 | | |
487 | 519 | | |
| |||
514 | 546 | | |
515 | 547 | | |
516 | 548 | | |
517 | | - | |
| 549 | + | |
518 | 550 | | |
519 | 551 | | |
520 | 552 | | |
| |||
530 | 562 | | |
531 | 563 | | |
532 | 564 | | |
533 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
534 | 570 | | |
535 | 571 | | |
536 | 572 | | |
537 | 573 | | |
538 | 574 | | |
539 | | - | |
| 575 | + | |
540 | 576 | | |
541 | 577 | | |
542 | | - | |
| 578 | + | |
543 | 579 | | |
544 | 580 | | |
545 | 581 | | |
| |||
568 | 604 | | |
569 | 605 | | |
570 | 606 | | |
571 | | - | |
| 607 | + | |
572 | 608 | | |
573 | 609 | | |
574 | 610 | | |
| |||
609 | 645 | | |
610 | 646 | | |
611 | 647 | | |
612 | | - | |
| 648 | + | |
613 | 649 | | |
614 | 650 | | |
615 | 651 | | |
| |||
633 | 669 | | |
634 | 670 | | |
635 | 671 | | |
636 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
637 | 681 | | |
638 | 682 | | |
639 | 683 | | |
| |||
649 | 693 | | |
650 | 694 | | |
651 | 695 | | |
652 | | - | |
| 696 | + | |
653 | 697 | | |
654 | 698 | | |
655 | 699 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1291 | 1291 | | |
1292 | 1292 | | |
1293 | 1293 | | |
1294 | | - | |
| 1294 | + | |
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
| |||
1307 | 1307 | | |
1308 | 1308 | | |
1309 | 1309 | | |
1310 | | - | |
| 1310 | + | |
1311 | 1311 | | |
1312 | 1312 | | |
1313 | 1313 | | |
| |||
0 commit comments