Skip to content

docs(i18n): adopt gettext PO as the canonical translation source - #11478

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/i18n-po-translation-source
Jul 31, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/i18n-po-translation-source

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

Records the translation-source architecture decision for Orca localization in config/i18n-translation-source.md and 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:

  • PO field mapping: 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.
  • A strict responsibility split: feature PRs change English only; a read-only compiler joins current English with target PO files and omits stale or pending-approval entries (English fallback works before any reconciliation runs); post-merge localization automation owns all PO mutations in localization-only changes.
  • Why gettext merge tooling cannot own the join under stable IDs (msgmerge keys on the (msgctxt, msgid) pair, so a source change orphans the entry instead of marking it fuzzy) — the reconciler joins by msgctxt alone.
  • A four-state entry taxonomy (missing / stale / pending approval / current-approved), with machine-vs-human provenance recorded separately from runtime eligibility.
  • Message ID and placeholder policy: existing content-hash IDs are grandfathered as opaque stable IDs; new keys require intent names and named interpolation placeholders.
  • Scope for the mobile catalog tree and plugin language packs, state-dependent placeholder validation, an identical-to-English ratchet with reviewed exemptions, and a field-by-field PR B acceptance gate that cannot pass vacuously on a lossy round-trip.
  • XLIFF is relegated to an optional provider import/export adapter; the fallback if the PO proof fails is a bespoke bilingual JSON schema, explicitly not XLIFF.

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 lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Docs-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 --check passes 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

  • The decision document intentionally defers implementation: PR B (constrained PO profile, read-only compiler, reconciliation command, field-by-field fixtures) is the next step and closes the decision gate.
  • PR A created a deletion ratchet (extra target-locale keys hard-fail, so English keys cannot be retired without editing every target catalog); orphaned English keys grow with every rename, so PR C should follow PR B without a long gap — this is now recorded in the rollout section.
  • Mobile must adopt the same canonical contract with its own PO files rather than a second bespoke pipeline; mobile keys must not be folded into the desktop catalogs.

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.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Documents 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)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adopting gettext PO as the canonical translation source.
Description check ✅ Passed The description follows the required template and includes summary, screenshots, testing, AI review, security audit, and notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This 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.

  • New ADR (i18n-translation-source.md): Documents the constrained PO field mapping, the strict responsibility split (feature PRs → English only; read-only compiler → bundle generation; post-merge automation → all PO mutations), and the rationale for the reconciler owning joins by msgctxt alone.
  • localization-audit.md correction: Updates the coverage allowlist description from "empty" to the accurate count of 10 reviewed entries and adds a cross-link to the new decision document.

Confidence Score: 5/5

Docs-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.

Important Files Changed

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 80c42d3 and 4501ac8.

📒 Files selected for processing (2)
  • config/i18n-translation-source.md
  • config/localization-audit.md

Comment on lines +72 to +75
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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
fi

Repository: 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
fi

Repository: 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:


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.

Suggested change
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.

@brennanb2025
brennanb2025 merged commit 5d88c10 into main Jul 31, 2026
39 of 41 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/i18n-po-translation-source branch July 31, 2026 18:46
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant