Skip to content

Commit ddc6968

Browse files
committed
l10n: README: add AI agent guidelines
AI agents can significantly improve the efficiency of l10n translation and quality checking. Add guidelines to help AI agents better perform translation and quality review tasks. 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 bd5cf5a commit ddc6968

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

po/README.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,163 @@ 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 and fuzzy 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+
If you only want the message IDs, you can pipe to:
514+
515+
```shell
516+
msgattrib --untranslated --no-obsolete po/XX.po | sed -n '/^msgid /,/^$/p'
517+
```
518+
519+
```shell
520+
msgattrib --only-fuzzy --no-obsolete po/XX.po | sed -n '/^msgid /,/^$/p'
521+
```
522+
523+
524+
### Translation workflow (`po/XX.po`)
525+
526+
- Generate `po/git.pot` from source code.
527+
- Update `po/XX.po` with the new template.
528+
- Translate new entries identified by `msgattrib --untranslated` (see above).
529+
- Fix fuzzy entries identified by `msgattrib --only-fuzzy` (see above) by
530+
re-translating and removing the `fuzzy` tag after updating `msgstr`.
531+
- Apply the quality checklist to every translation.
532+
533+
534+
### Review workflow
535+
536+
#### Full file review
537+
538+
When explicitly asked to review all translated content, review `po/XX.po`
539+
in chunks. Unless otherwise specified, update `po/XX.po` directly; if a summary
540+
is requested, provide a consolidated report of the issues. Apply the quality
541+
checklist to each message you review.
542+
543+
544+
#### Patch review
545+
546+
Review requests may come as patches of `po/XX.po`:
547+
548+
- Workspace changes: `git diff HEAD -- po/XX.po`
549+
- Changes since a commit-ish: `git diff <commit-ish> -- po/XX.po`
550+
- Changes in a specific commit: `git show <commit-ish> -- po/XX.po`
551+
552+
When diff context is incomplete (truncated `msgid` or `msgstr`), use file
553+
viewing tools to pull nearby context for accurate review. Apply the same
554+
quality checklist as in full file reviews. If the patch is based on workspace
555+
changes, update `po/XX.po` directly unless a summary is requested; if the patch
556+
is from a specific commit, report issues or apply fixes when comparing against
557+
the current `po/XX.po` in the workspace.
558+
559+
560+
### Handling large inputs
561+
562+
When a `po/XX.po` file or a patch is too large for LLM context, split it into
563+
chunks while keeping `msgid` and `msgstr` pairs intact. This includes plural
564+
forms: `msgid`, `msgid_plural`, `msgstr[0]`, `msgstr[1]`, and any additional
565+
plural indices required by the language.
566+
567+
For `po/XX.po`, split on the line immediately before each `msgid` entry. This
568+
guarantees no chunk begins with an unpaired `msgid`. Use
569+
`grep -n '^msgid' po/XX.po` to locate split points, and group the file into
570+
chunks of no more than 200 `msgid` entries (about 50K bytes each).
571+
572+
For patch files, check the patch size first:
573+
574+
- If the patch is <= 100KB, do not split.
575+
- If the patch is > 100KB, split it using the same rule as for `po/XX.po`:
576+
split on the line immediately before each `msgid` entry so message pairs
577+
stay together.
578+
579+
580+
### Plural forms
581+
582+
For entries with `msgid_plural`, provide plural forms:
583+
584+
```po
585+
msgid "..."
586+
msgid_plural "..."
587+
msgstr[0] "..."
588+
msgstr[1] "..."
589+
```
590+
591+
Use `msgstr[0]`/`msgstr[1]` as required. If the language has more plural forms,
592+
follow the `Plural-Forms` header in `po/XX.po` to determine the required number
593+
of `msgstr[n]` entries.
594+
595+
596+
### Placeholder reordering
597+
598+
When a translation reorders placeholders, mark them with positional parameter
599+
syntax (`%n$`) so each argument maps to the correct source value. Keep the
600+
width/precision modifiers intact and place the position specifier before them.
601+
602+
Example:
603+
604+
```po
605+
msgid "missing environment variable '%s' for configuration '%.*s'"
606+
msgstr "配置 '%3$.*2$s' 缺少环境变量 '%1$s'"
607+
```
608+
609+
Here the translation swaps the two placeholders. `%1$s` still refers to the
610+
first argument (`%s`), while `%3$.*2$s` refers to the third string argument
611+
with the precision taken from the second argument (`%.*s`).
612+
613+
614+
### Example prompts for AI agents
615+
616+
- Refer to @po/README.md to update translations in po/XX.po.
617+
- Refer to @po/README.md to review all translations in po/XX.po.
618+
619+
462620
[git-po-helper/README]: https://github.com/git-l10n/git-po-helper#readme
463621
[Documentation/SubmittingPatches]: Documentation/SubmittingPatches

0 commit comments

Comments
 (0)