Repository navigation
docs(i18n): adopt gettext PO as the canonical translation source - #11478
Conversation
Records the revised translation-source architecture decision: gettext PO replaces the original constrained XLIFF 2.0 profile after tooling, contributor-workflow, and repository-evidence review. Documents the read-only compiler / post-merge reconciler split, the four-state entry taxonomy, message ID and placeholder policy, mobile and plugin-language-pack scope, and the field-by-field PR B acceptance gate. Links the decision from the localization audit and corrects its allowlist description.
📝 WalkthroughWalkthroughDocuments a gettext PO-based translation architecture for Orca, including source ownership, entry state handling, compiler validation, deterministic i18next bundle generation, placeholder and message ID policies, platform projections, reconciliation automation, and staged migration requirements. It also records evaluated alternatives, proof criteria, non-goals, and updates the localization audit with architecture references and reviewed coverage allowlist guidance. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR records the architecture decision to adopt gettext PO as Orca's canonical bilingual translation source, replacing the previously selected XLIFF 2.0 profile. It adds a new 524-line decision document and makes a small factual correction to the localization audit.
Confidence Score: 5/5Docs-only change — no code, build surface, or test surface is touched; safe to merge. Both files are pure documentation. The new ADR is technically consistent: the msgmerge keying claim, four-state taxonomy, responsibility split, and PR B acceptance gate are all accurate and non-contradictory. The localization-audit.md correction (1+5+4=10) is arithmetically correct. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| config/i18n-translation-source.md | New architecture decision record selecting gettext PO as the canonical translation source. Technical claims about PO field semantics and msgmerge behavior are accurate, the responsibility split is clearly specified, and the decision gate for PR B is concrete and non-vacuous. |
| config/localization-audit.md | Minor correction: updates the allowlist description from 'empty' to '10 reviewed entries' with a breakdown (1 + 5 + 4 = 10), which is internally consistent; adds a cross-link to the new decision document. |
Reviews (2): Last reviewed commit: "docs(i18n): add mobile dual-projection a..." | Re-trigger Greptile
From PR 11446 owner review: mobile needs two deterministic projections (i18next JSON + pre-JS native metadata with a documented native fallback rule and the zh/zh-Hans locale-ID mapping); the hash-ID grandfather clause is date-scoped to the desktop catalog so freshly minted bridge IDs must be renamed in a dedicated adjacent change; OS permission prompts and native app metadata join the human-review list; imported bridge provenance must be classified in PR C.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cf041757-e742-4133-be30-1618a0fc818d
📒 Files selected for processing (2)
config/i18n-translation-source.mdconfig/localization-audit.md
| The reconciler — not gettext's own merge tooling — owns the join. `msgmerge` | ||
| keys entries on the `(msgctxt, msgid)` pair, so under stable IDs a source | ||
| change orphans the entry instead of marking it fuzzy. Reconciliation must join | ||
| by `msgctxt` alone. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the referenced documentation text and surrounding context.
if [ -f config/i18n-translation-source.md ]; then
nl -ba config/i18n-translation-source.md | sed -n '50,90p'
else
echo "Missing config/i18n-translation-source.md"
fd -a 'i18n-translation-source\.md|translation-source' .
fi
echo "--- gettext msgmerge docs excerpts from local/manual if available ---"
if command -v msgmerge >/dev/null 2>&1; then
msgmerge --help | sed -n '1,80p' || true
man msg 2>/dev/null | rg -n -i 'msgmerge|fuzzy|exact match|msgctxt|msgid' -C 3 | sed -n '1,160p' || true
fi
echo "--- search for msgmerge explanations in repo ---"
rg -n "msgmerge|heuristic|fuzzy match|msgctxt|msgmerge" . --glob '!node_modules/**' --glob '!vendor/**' | sed -n '1,120p'
echo "--- external docs if curl available ---"
if command -v curl >/dev/null 2>&1; then
curl -sS "https://www.gnu.org/software/gettext/manual/html_node/msgmerge-Invocation.html" 2>/dev/null | \
sed -n '/<h1 title.*msgmerge/,/<h1/p' | \
sed -n '/exact matching/,/matching/ { p; }' | sed -n '1,180p' || true
fiRepository: stablyai/orca
Length of output: 191
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Working dir:"
pwd
echo "--- locate doc file(s) ---"
find . -maxdepth 4 -type f \( -name 'i18n-translation-source.md' -o -name '*translation-source*' -o -name '*i18n*' \) 2>/dev/null | sort | sed -n '1,80p'
if [ -f config/i18n-translation-source.md ]; then
echo "--- config/i18n-translation-source.md lines 60-80 ---"
awk 'NR>=60 && NR<=80 { printf "%4d\t%s\n", NR, $0 }' config/i18n-translation-source.md
fi
echo "--- msgmerge command/docs if available ---"
command -v msgmerge || true
msgmerge --version 2>&1 | sed -n '1,10p' || true
msgmerge --help 2>&1 | sed -n '1,120p' || true
echo "--- search repo for msgmerge/fuzzy/exact terminology ---"
grep -RIn -E "msgmerge|heuristic fuzzy|fuzzy matching|fuzzy match|exact matching|msgctxt.*msgid|msgmerge keys|orphan" . --global-binary-path-filter=0 --exclude-dir=node_modules --exclude-dir=vendor --exclude-dir=.git 2>/dev/null | sed -n '1,160p' || true
echo "--- fetch gettext manual excerpt with curl if available ---"
if command -v curl >/dev/null 2>&1; then
url="https://www.gnu.org/software/gettext/manual/html_node/msgmerge-Invocation.html"
tmp="/tmp/msgmerge-man.html"
status=$(curl -sS -o "$tmp" -w "%{http_code}" "$url" 2>/dev/null || echo "curl-failed")
echo "curl-status=$status"
if [ "$status" = "200" ]; then
sed -n '/exact matching/,/matching/p' "$tmp" | sed -n '1,220p' || true
fi
fi
echo "--- fetch gettext manual excerpt with wget if available ---"
if command -v wget >/dev/null 2>&1; then
tmp="/tmp/msgmerge-man-wget.html"
status=$(wget -qO "$tmp" "https://www.gnu.org/software/gettext/manual/html_node/msgmerge-Invocation.html" 2>/dev/null && echo 200 || echo "wget-failed")
echo "wget-status=$status"
if [ "$status" = "200" ]; then
sed -n '/exact matching/,/matching/p' "$tmp" | sed -n '1,220p' || true
fi
fiRepository: stablyai/orca
Length of output: 143
🌐 Web query:
GNU gettext msgmerge Invocation exact matching heuristic fuzzy matching msgctxt msgid
💡 Result:
In GNU gettext, msgmerge uses a fuzzy matching heuristic to associate translations from an existing PO file with messages in a new POT file when an exact match for the msgid (optionally qualified by msgctxt) is not found [1][2]. The fuzzy matching process operates as follows: 1. Identification: If msgmerge cannot find an exact match for a given message in the existing catalog (matching both msgctxt and msgid), it invokes its fuzzy matching logic [1][3][4]. 2. Heuristic Matching: msgmerge calculates a similarity score between the new message and available translations using a goal function [3][5]. This score determines how closely the strings align [6]. 3. Threshold: Only messages with a goal function value exceeding a defined threshold (FUZZY_THRESHOLD, currently set to 0.6) are considered as potential fuzzy matches [5][7]. 4. Optimization: To handle large translation files efficiently, msgmerge uses a "fuzzy index" (a data structure) that allows for optimized searching [7]. When searching this index, a heuristic approach is used to focus on the most promising candidates rather than checking every single message, which improves performance [3][7]. 5. Selection: If a match is found that satisfies the threshold, the old translation is reused but marked as "fuzzy" (using the #, fuzzy flag) to notify the translator that the match is not exact and requires review [3][4][6]. 6. Constraints: If --no-fuzzy-matching is used, msgmerge skips this entire heuristic process, resulting in significantly faster performance but fewer automatic matches [1][8]. The msgctxt field, if present, is treated as a component of the message identity alongside the msgid, ensuring that fuzzy matching respects context-specific strings [3][5][7].
Citations:
- 1: https://www.gnu.org.cach3.com/software/gettext/manual/html_node/msgmerge-Invocation.html
- 2: https://man.archlinux.org/man/msgmerge.1.en.raw
- 3: https://github.com/lesta-games/gettext/blob/master/gettext-tools/src/msgmerge.c
- 4: http://ftp.pkgsrc.org/pub/NetBSD/NetBSD-release-9/src/external/gpl2/gettext/dist/gettext-tools/src/msgmerge.c
- 5: https://github.com/lesta-games/gettext/blob/master/gettext-tools/src/message.h
- 6: https://stackoverflow.com/questions/27146659/why-msgmerge-marked-some-of-my-translation-as-fuzzy
- 7: https://fossies.org/dox/gettext-1.0/msgl-fsearch_8h_source.html
- 8: https://fossies.org/linux/gettext/gettext-tools/doc/gettext_7.html
Correct the msgmerge behavior description.
msgmerge uses (msgctxt, msgid) for exact matching, then applies fuzzy matching when exact matching fails; source changes can therefore be marked fuzzy rather than always orphaned. Keep the stable-ID rationale: msgmerge’s heuristic fuzzy behavior is not the required contract, so reconciliation should still join by msgctxt alone.
Proposed wording
-msgmerge keys entries on the `(msgctxt, msgid)` pair, so under stable IDs a source
-change orphans the entry instead of marking it fuzzy. Reconciliation must join
-by `msgctxt` alone.
+msgmerge uses the `(msgctxt, msgid)` pair for exact matching and may apply
+heuristic fuzzy matching when the source changes. Because that does not provide
+the required stable-ID contract, reconciliation must join by `msgctxt` alone.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The reconciler — not gettext's own merge tooling — owns the join. `msgmerge` | |
| keys entries on the `(msgctxt, msgid)` pair, so under stable IDs a source | |
| change orphans the entry instead of marking it fuzzy. Reconciliation must join | |
| by `msgctxt` alone. | |
| The reconciler — not gettext's own merge tooling — owns the join. `msgmerge` | |
| uses the `(msgctxt, msgid)` pair for exact matching and may apply | |
| heuristic fuzzy matching when the source changes. Because that does not provide | |
| the required stable-ID contract, reconciliation must join by `msgctxt` alone. |
…blyai#11478) * docs(i18n): adopt gettext PO as the canonical translation source Records the revised translation-source architecture decision: gettext PO replaces the original constrained XLIFF 2.0 profile after tooling, contributor-workflow, and repository-evidence review. Documents the read-only compiler / post-merge reconciler split, the four-state entry taxonomy, message ID and placeholder policy, mobile and plugin-language-pack scope, and the field-by-field PR B acceptance gate. Links the decision from the localization audit and corrects its allowlist description. * docs(i18n): add mobile dual-projection and bridge-ID constraints From PR 11446 owner review: mobile needs two deterministic projections (i18next JSON + pre-JS native metadata with a documented native fallback rule and the zh/zh-Hans locale-ID mapping); the hash-ID grandfather clause is date-scoped to the desktop catalog so freshly minted bridge IDs must be renamed in a dedicated adjacent change; OS permission prompts and native app metadata join the human-review list; imported bridge provenance must be classified in PR C.
Summary
Records the translation-source architecture decision for Orca localization in
config/i18n-translation-source.mdand links it from the localization audit. The staged architecture from PR A (#8512) is unchanged — stable message IDs, sparse target catalogs, English fallback, deterministic compilation to the existing i18next JSON bundles, delta-driven translation automation — but the canonical bilingual format decision is revised from a constrained XLIFF 2.0 profile to gettext PO after a tooling, contributor-workflow, and repository-evidence review resolved the format uncertainty the original decision had explicitly flagged.Key points the document now records:
msgctxt= stable ID,msgid= current English as of last reconciliation,#, fuzzy= not approved for runtime,#| msgid= prior source,#.= translator context,#~= retired under a deterministic retention policy.msgmergekeys on the(msgctxt, msgid)pair, so a source change orphans the entry instead of marking it fuzzy) — the reconciler joins bymsgctxtalone.Also corrects the localization audit's description of the coverage allowlist (it contains 10 reviewed entries, not zero) and cross-links the decision document.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildDocs-only change (two Markdown files under
config/); no code, build surface, or test surface is affected, so the code gates above do not exercise this diff.git diff --checkpasses and the documents were grep-audited for internal consistency (state taxonomy, compiler/reconciler responsibilities, source-comparison semantics).AI Review Report
The decision revision was driven by an AI-agent evidence review across four streams: empirical probes of the candidate format libraries (the dominant JS XLIFF library silently discards workflow state and note categories while reporting a clean round-trip — the vacuous-round-trip failure mode now documented in the PR B gate; the maintained PO parser preserved state, previous source, notes, plurals, and retired entries idempotently), repository ground truth (catalog shape, key-naming and placeholder debt, the orphaned-English-key ratchet created by PR A, plugin language packs, mobile's separate catalog tree), the in-flight localization PR set (contribution arrives overwhelmingly as direct catalog edits from community forks), and format/tool ecosystem support. A second independent review pass caught and fixed an architectural contradiction (the compiler originally mutated PO files, conflicting with "deterministic and disposable" and "feature PRs never touch target catalogs") plus source-comparison semantics and state-taxonomy overlaps. Cross-platform compatibility was explicitly considered: the document mandates cross-platform path handling and deterministic line endings for the compiler and build paths across macOS, Linux, Windows, WSL, and SSH execution; no shortcuts, labels, paths, or shell behavior change in this PR itself.
Security Audit
Docs-only: no input handling, command execution, path handling, auth, secrets, or IPC changes. Supply-chain posture was part of the format evidence: the decision avoids committing Orca's canonical format to a low-adoption single-maintainer EPL-1.0 dependency and notes the maintained MIT-licensed PO tooling; the document also preserves the existing plugin language-pack validation boundary (external overrides validated against compiled core keys, never a canonical source). No follow-up needed for this change.
Notes