Commit

b2bc011edd388c3e2f4d7e2b22d3463315faf6d5

l10n: AGENTS.md: require git-po-helper >= 0.9.1

Task 3 claimed a gettext-only fallback, but validation already needs
git-po-helper, and the awk|tac batch path fails on systems without tac.
Require the helper for Tasks 3 and 4, drop the unused msgattrib/PO
paths, and point agents at msg-select (with msgattrib still noted as an
option).

Pin to git-po-helper >= 0.9.1 to rely on new helper features: version
comparison for the minimum version check, and `git-po-helper stat -c`
used by the next commit to count PO entries.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>

Jiang Xin <worldhello.net@gmail.com> · 2026-09-17 07:58 UTC

Browse files
1 file changed, +34 −80
modified po/AGENTS.md
@@ -93,17 +93,9 @@ msgstr ""
93 93
94 94 **CRITICAL**: Do **not** use `grep '^msgstr ""'` to find untranslated entries;
95 95 multi-line `msgstr` blocks use the same opening line, so grep gives false
96 - positives. Use `msgattrib` (next section).
97 -
98 -
99 - ### Locating untranslated, fuzzy, and obsolete entries
100 -
101 - Use `msgattrib` to list untranslated, fuzzy, and obsolete entries. Task 3
102 - (translating `po/XX.po`) uses these commands.
103 -
104 - - **Untranslated**: `msgattrib --untranslated --no-obsolete po/XX.po`
105 - - **Fuzzy**: `msgattrib --only-fuzzy --no-obsolete po/XX.po`
106 - - **Obsolete** (`#~`): `msgattrib --obsolete --no-wrap po/XX.po`
96 + positives. Use `git-po-helper msg-select` with `--untranslated` / `--fuzzy`
97 + (see Task 3), or `msgattrib` (e.g. `--untranslated`, `--only-fuzzy`,
98 + `--obsolete`).
107 99
108 100
109 101 ### Translating fuzzy entries
@@ -238,8 +230,19 @@ On failure, `msgfmt` prints the line number; fix the PO at that line.
238 230
239 231 [git-po-helper](https://github.com/git-l10n/git-po-helper) supports Git l10n with
240 232 **quality checking** (git-l10n PR conventions) and **AI-assisted translation**
241 - (subcommands for automated workflows). Housekeeping tasks in this document use
242 - it when available; otherwise rely on gettext tools.
233 + (subcommands for automated workflows). Task 3 (translating) and Task 4
234 + (reviewing) **require** `git-po-helper` **>= 0.9.1**. Task 1 and Task 2 use
235 + `make` / gettext tooling instead.
236 +
237 + **Version check**: Before Task 3 or Task 4, run:
238 +
239 + ```shell
240 + git-po-helper version --ge 0.9.1
241 + ```
242 +
243 + If the command is missing or the exit status is non-zero, print the error (use
244 + the command's own output when available) and **refuse** the task; do not
245 + continue.
243 246
244 247
245 248 #### Splitting large PO files
@@ -476,9 +479,9 @@ When asked to update `po/XX.po` (or the like):
476 479
477 480 ### Task 3: Translating po/XX.po
478 481
479 - To translate `po/XX.po`, use the steps below. The script uses gettext or
480 - `git-po-helper` depending on what is installed; JSON export (when available)
481 - supports batch translation rather than per-entry work.
482 + To translate `po/XX.po`, use the steps below. **Require** `git-po-helper` (see
483 + "Using git-po-helper" for the version check); without a passing check, refuse
484 + the task. Batches are GETTEXT JSON for translation.
482 485
483 486 **Workflow loop**: Steps 1→2→3→4→5→6→7 form a loop. After step 6 succeeds,
484 487 **always** go to step 7, which returns to step 1. The **only** exit to step 8
@@ -494,21 +497,9 @@ step 8 after step 6.
494 497 test $# -ge 1 || { echo "Usage: l10n_extract_pending <po-file>" >&2; return 1; }
495 498 PO_FILE="$1"
496 499 PENDING="po/l10n-pending.po"
497 - PENDING_FUZZY="${PENDING}.fuzzy"
498 - PENDING_REFER="${PENDING}.fuzzy.reference"
499 - PENDING_UNTRANS="${PENDING}.untranslated"
500 500 rm -f "$PENDING"
501 501
502 - if command -v git-po-helper >/dev/null 2>&1
503 - then
504 - git-po-helper msg-select --untranslated --fuzzy --no-obsolete -o "$PENDING" "$PO_FILE"
505 - else
506 - msgattrib --untranslated --no-obsolete "$PO_FILE" >"${PENDING_UNTRANS}"
507 - msgattrib --only-fuzzy --no-obsolete --clear-fuzzy --empty "$PO_FILE" >"${PENDING_FUZZY}"
508 - msgattrib --only-fuzzy --no-obsolete "$PO_FILE" >"${PENDING_REFER}"
509 - msgcat --use-first "${PENDING_UNTRANS}" "${PENDING_FUZZY}" >"$PENDING"
510 - rm -f "${PENDING_UNTRANS}" "${PENDING_FUZZY}"
511 - fi
502 + git-po-helper msg-select --untranslated --fuzzy --no-obsolete -o "$PENDING" "$PO_FILE"
512 503 if test -s "$PENDING"
513 504 then
514 505 msgfmt --stat -o /dev/null "$PENDING" || true
@@ -528,8 +519,7 @@ step 8 after step 6.
528 519 3. **Prepare one batch for translation**: Batching keeps each run small so the
529 520 model can complete translation within limited context. **BEFORE translating**,
530 521 **directly execute** the script below—it is authoritative; do not reimplement.
531 - Based on which file the script produces: if `po/l10n-todo.json` exists, go to
532 - step 4a; if `po/l10n-todo.po` exists, go to step 4b.
522 + It writes `po/l10n-todo.json`; then go to step 4.
533 523
534 524 ```shell
535 525 l10n_one_batch () {
@@ -538,10 +528,9 @@ step 8 after step 6.
538 528 min_batch_size=${2:-100}
539 529 PENDING="po/l10n-pending.po"
540 530 TODO_JSON="po/l10n-todo.json"
541 - TODO_PO="po/l10n-todo.po"
542 531 DONE_JSON="po/l10n-done.json"
543 532 DONE_PO="po/l10n-done.po"
544 - rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO"
533 + rm -f "$TODO_JSON" "$DONE_JSON" "$DONE_PO"
545 534
546 535 ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true)
547 536 ENTRY_COUNT=${ENTRY_COUNT:-0}
@@ -557,39 +546,18 @@ step 8 after step 6.
557 546 else
558 547 NUM=$min_batch_size
559 548 fi
560 - BATCHING=1
549 + git-po-helper msg-select --json --head "$NUM" -o "$TODO_JSON" "$PENDING"
550 + echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)"
561 551 else
562 - NUM=$ENTRY_COUNT
563 - BATCHING=
564 - fi
565 -
566 - if command -v git-po-helper >/dev/null 2>&1
567 - then
568 - if test -n "$BATCHING"
569 - then
570 - git-po-helper msg-select --json --head "$NUM" -o "$TODO_JSON" "$PENDING"
571 - echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)"
572 - else
573 - git-po-helper msg-select --json -o "$TODO_JSON" "$PENDING"
574 - echo "Processing all $ENTRY_COUNT entries at once"
575 - fi
576 - else
577 - if test -n "$BATCHING"
578 - then
579 - awk -v num="$NUM" '/^msgid / && count++ > num {exit} 1' "$PENDING" |
580 - tac | awk '/^$/ {found=1} found' | tac >"$TODO_PO"
581 - echo "Processing batch of $NUM entries (out of $ENTRY_COUNT remaining)"
582 - else
583 - cp "$PENDING" "$TODO_PO"
584 - echo "Processing all $ENTRY_COUNT entries at once"
585 - fi
552 + git-po-helper msg-select --json -o "$TODO_JSON" "$PENDING"
553 + echo "Processing all $ENTRY_COUNT entries at once"
586 554 fi
587 555 }
588 556 # Prepare one batch; shrink 2nd arg when batches exceed agent capacity.
589 557 l10n_one_batch po/XX.po 100
590 558 ```
591 559
592 - 4a. **Translate JSON batch** (`po/l10n-todo.json` → `po/l10n-done.json`):
560 + 4. **Translate JSON batch** (`po/l10n-todo.json` → `po/l10n-done.json`):
593 561
594 562 - **Task**: Translate `po/l10n-todo.json` (input, GETTEXT JSON) into
595 563 `po/l10n-done.json` (output, GETTEXT JSON). See the "GETTEXT JSON format"
@@ -604,18 +572,6 @@ step 8 after step 6.
604 572 (for plural entries); clear the fuzzy flag (omit or set `fuzzy` to `false`).
605 573 Do **not** modify `msgid` or `msgid_plural`.
606 574
607 - 4b. **Translate PO batch** (`po/l10n-todo.po` → `po/l10n-done.po`):
608 -
609 - - **Task**: Translate `po/l10n-todo.po` (input, GETTEXT PO) into
610 - `po/l10n-done.po` (output, GETTEXT PO).
611 - - **Reference glossary**: Read the glossary from the pending file header
612 - (see "Glossary Section" above) and use it for consistent terminology.
613 - - **When translating**: Follow the "Quality checklist" above for correctness
614 - and quality. Preserve escape sequences (`\n`, `\"`, `\\`, `\t`), placeholders,
615 - and quotes as in `msgid`. Modify `msgstr` and `msgstr[n]` (for plural
616 - entries); remove the `#, fuzzy` tag from comments when done. Do **not**
617 - modify `msgid` or `msgid_plural`.
618 -
619 575 5. **Validate `po/l10n-done.po`**:
620 576
621 577 Run the validation script below. If it fails, fix per the errors and notes,
@@ -685,10 +641,7 @@ step 8 after step 6.
685 641 DONE_PO="po/l10n-done.po"
686 642 DONE_JSON="po/l10n-done.json"
687 643 MERGED="po/l10n-done.merged"
688 - PENDING="po/l10n-pending.po"
689 - PENDING_REFER="${PENDING}.fuzzy.reference"
690 644 TODO_JSON="po/l10n-todo.json"
691 - TODO_PO="po/l10n-todo.po"
692 645 if test -f "$DONE_JSON" && { ! test -f "$DONE_PO" || test "$DONE_JSON" -nt "$DONE_PO"; }
693 646 then
694 647 git-po-helper msg-cat --unset-fuzzy -o "$DONE_PO" "$DONE_JSON" || {
@@ -701,7 +654,7 @@ step 8 after step 6.
701 654 return 1
702 655 }
703 656 mv "$MERGED" "$PO_FILE"
704 - rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO" "$PENDING_REFER"
657 + rm -f "$TODO_JSON" "$DONE_JSON" "$DONE_PO"
705 658 }
706 659 # Run the merge. Example: l10n_merge_batch po/zh_CN.po
707 660 l10n_merge_batch po/XX.po
@@ -726,11 +679,12 @@ commit. When asked to review, follow the steps below.
726 679
727 680 **Workflow**: Follow steps in order. Do **NOT** use `git show`, `git diff`,
728 681 `git format-patch`, or similar to get changes—they break PO context; use **only**
729 - `git-po-helper compare` for extraction. Without `git-po-helper`, refuse the task.
730 - Steps 3→4→5→6→7 loop: after step 6, **always** go to step 7 (back to step 3).
731 - The **only** ways to step 8 are when step 4 finds `po/review-todo.json` missing
732 - or empty (no batch left to review), or when step 1 finds `po/review-result.json`
733 - already present.
682 + `git-po-helper compare` for extraction. **Require** `git-po-helper` (see
683 + "Using git-po-helper" for the version check); without a passing check, refuse
684 + the task. Steps 3→4→5→6→7 loop: after step 6, **always** go to step 7 (back to
685 + step 3). The **only** ways to step 8 are when step 4 finds `po/review-todo.json`
686 + missing or empty (no batch left to review), or when step 1 finds
687 + `po/review-result.json` already present.
734 688
735 689 1. **Check for existing review (resume support)**: Evaluate the following in order:
736 690