Skip to content

Commit 8f67c11

Browse files
committed
l10n: README: add AI agent guidelines
AI agents can significantly improve the efficiency and consistency of localization tasks, including translation and quality assurance. Adds clear guidelines to help AI agents perform these tasks more effectively by referencing standardized practices. Additionally, the `git-po-helper` command has been slightly adjusted to better support AI agent workflows. Examples of prompts for AI agents: - Refer to @po/README.md to update translations in po/XX.po. - Refer to @po/README.md to review all translations in po/XX.po. Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
1 parent 00d6cbf commit 8f67c11

File tree

1 file changed

+179
-3
lines changed

1 file changed

+179
-3
lines changed

po/README.md

Lines changed: 179 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ L10n coordinator will check your contributions using a helper program
227227
(see "PO helper" section below):
228228

229229
```shell
230-
git-po-helper check-po po/XX.po
231-
git-po-helper check-commits <rev-list-opts>
230+
git-po-helper check-po --pot-file=build po/XX.po
231+
git-po-helper check-commits --pot-file=build <rev-list-opts>
232232
```
233233

234234

@@ -430,7 +430,7 @@ There are some conventions that l10n contributors must follow:
430430
your commit:
431431

432432
```shell
433-
git-po-helper check-po <XX.po>
433+
git-po-helper check-po --pot-file=build <XX.po>
434434
```
435435

436436
- Squash trivial commits to make history clear.
@@ -459,5 +459,181 @@ additional conventions:
459459
```
460460

461461

462+
## AI Agent Guidelines
463+
464+
These guidelines help AI agents translate and review Git core messages
465+
consistently and accurately.
466+
467+
### Scope and context
468+
469+
- Primary files: `po/XX.po` for translations, `po/git.pot` for the source
470+
template.
471+
- Source language: English. Target language: derived from the language code in
472+
the `po/XX.po` filename based on ISO 639 and ISO 3166.
473+
- Glossary: Git l10n teams may add glossary sections (e.g. "Git glossary for
474+
Chinese translators") in the header comments of `po/XX.po` immediately before
475+
the first `msgid` entry. If a glossary exists, read it and keep terminology
476+
consistent.
477+
478+
479+
### Quality checklist
480+
481+
- Accuracy: faithfully conveys the original meaning; no omissions or distortions.
482+
- Terminology: uses correct, consistent terms per glossary or domain standards.
483+
- Grammar and fluency: grammatically correct and reads naturally.
484+
- Placeholders: preserves variables (e.g. `%s`, `{name}`, `$1`) exactly. If
485+
reordering is needed for the target language, use positional parameters as
486+
described below.
487+
- Plurals and gender: handles plural forms, gender, and agreement correctly.
488+
- Context fit: suitable for UI space, tone, and usage (e.g. error vs. tooltip).
489+
- Cultural appropriateness: avoids offensive or ambiguous content.
490+
- Consistency: matches prior translations of the same source string.
491+
- Technical integrity: do not translate code, paths, commands, brand names, or
492+
proper nouns.
493+
- Readability: clear, concise, and user-friendly.
494+
495+
496+
### Locating untranslated, fuzzy, and obsolete entries
497+
498+
Use GNU gettext tools to parse PO structure reliably (safe for multi-line
499+
`msgid`/`msgstr`):
500+
501+
- Untranslated entries:
502+
503+
```shell
504+
msgattrib --untranslated --no-obsolete po/XX.po
505+
```
506+
507+
- Fuzzy entries:
508+
509+
```shell
510+
msgattrib --only-fuzzy --no-obsolete po/XX.po
511+
```
512+
513+
- Obsolete entries (marked with `#~`):
514+
515+
```shell
516+
msgattrib --obsolete --no-wrap po/XX.po
517+
```
518+
519+
If you only want the message IDs, you can pipe to:
520+
521+
```shell
522+
msgattrib --untranslated --no-obsolete po/XX.po | sed -n '/^msgid /,/^$/p'
523+
```
524+
525+
```shell
526+
msgattrib --only-fuzzy --no-obsolete po/XX.po | sed -n '/^msgid /,/^$/p'
527+
```
528+
529+
530+
### Translation workflow (`po/XX.po`)
531+
532+
When asked to update translations, follow the steps in this section in order
533+
and reference this section in your plan before making edits.
534+
535+
- Generate `po/git.pot` from source code.
536+
- Update `po/XX.po` with the new template.
537+
- Translate new entries identified by `msgattrib --untranslated` (see above).
538+
- Fix fuzzy entries identified by `msgattrib --only-fuzzy` (see above) by
539+
re-translating and removing the `fuzzy` tag after updating `msgstr`.
540+
- Remove obsolete entries (marked with `#~`) since we no longer keep them.
541+
- Apply the quality checklist to every translation.
542+
543+
544+
### Review workflow
545+
546+
Review workflow has two modes: direct review against local `po/XX.po`, and
547+
review based on a patch.
548+
549+
#### Full file review
550+
551+
- When explicitly asked to review all translated content, review `po/XX.po`
552+
in chunks (see [Handling large inputs](#handling-large-inputs) for splitting).
553+
- Apply the quality checklist to each message you review.
554+
- Remove obsolete entries (marked with `#~`) since they are no longer kept.
555+
- Unless otherwise specified, update `po/XX.po` directly; if a summary is
556+
requested, provide a consolidated report of the issues.
557+
558+
559+
#### Patch review
560+
561+
- Review requests may come as patches of `po/XX.po`:
562+
- Workspace changes: `git diff HEAD -- po/XX.po`
563+
- Changes since a commit-ish: `git diff <commit-ish> -- po/XX.po`
564+
- Changes in a specific commit: `git show <commit-ish> -- po/XX.po`
565+
- For large patches, follow the split guidance in
566+
[Handling large inputs](#handling-large-inputs) when splitting.
567+
- When diff context is incomplete (truncated `msgid` or `msgstr`), use file
568+
viewing tools to pull nearby context for accurate review.
569+
- Apply the same quality checklist as in full file reviews.
570+
- Obsolete entries (marked with `#~`) should be removed since they are no
571+
longer kept.
572+
- If the patch is based on workspace changes, update `po/XX.po` directly
573+
unless a summary is requested.
574+
- If the patch is from a specific commit, report issues or apply fixes when
575+
comparing against the current `po/XX.po` in the workspace.
576+
577+
578+
### Handling large inputs
579+
580+
When a `po/XX.po` file or a patch is too large for LLM context, split it into
581+
chunks while keeping `msgid` and `msgstr` pairs intact. This includes plural
582+
forms: `msgid`, `msgid_plural`, `msgstr[0]`, `msgstr[1]`, and any additional
583+
plural indices required by the language.
584+
585+
For `po/XX.po`, split on the line immediately before each `msgid` entry. This
586+
guarantees no chunk begins with an unpaired `msgid`. Use
587+
`grep -n '^msgid' po/XX.po` to locate split points, and group the file into
588+
chunks of no more than 200 `msgid` entries (about 50K bytes each).
589+
590+
For patch files, check the patch size first:
591+
592+
- If the patch is <= 100KB, do not split.
593+
- If the patch is > 100KB, split it using the same rule as for `po/XX.po`:
594+
split on the line immediately before each `msgid` entry so message pairs
595+
stay together.
596+
597+
598+
### Plural forms
599+
600+
For entries with `msgid_plural`, provide plural forms:
601+
602+
```po
603+
msgid "..."
604+
msgid_plural "..."
605+
msgstr[0] "..."
606+
msgstr[1] "..."
607+
```
608+
609+
Use `msgstr[0]`/`msgstr[1]` as required. If the language has more plural forms,
610+
follow the `Plural-Forms` header in `po/XX.po` to determine the required number
611+
of `msgstr[n]` entries.
612+
613+
614+
### Placeholder reordering
615+
616+
When a translation reorders placeholders, mark them with positional parameter
617+
syntax (`%n$`) so each argument maps to the correct source value. Keep the
618+
width/precision modifiers intact and place the position specifier before them.
619+
620+
Example:
621+
622+
```po
623+
msgid "missing environment variable '%s' for configuration '%.*s'"
624+
msgstr "配置 '%3$.*2$s' 缺少环境变量 '%1$s'"
625+
```
626+
627+
Here the translation swaps the two placeholders. `%1$s` still refers to the
628+
first argument (`%s`), while `%3$.*2$s` refers to the third string argument
629+
with the precision taken from the second argument (`%.*s`).
630+
631+
632+
### Example prompts for AI agents
633+
634+
- Refer to @po/README.md to update translations in po/XX.po.
635+
- Refer to @po/README.md to review all translations in po/XX.po.
636+
637+
462638
[git-po-helper/README]: https://github.com/git-l10n/git-po-helper#readme
463639
[Documentation/SubmittingPatches]: Documentation/SubmittingPatches

0 commit comments

Comments
 (0)