Skip to content

Commit 318ffb1

Browse files
Copilotbrunoborges
andcommitted
docs: add i18n plan recommendation for AI-driven translation workflow
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent aa556c5 commit 318ffb1

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

specs/i18n/recommendation.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# i18n Architecture Recommendation
2+
3+
## TL;DR — **Plan B is recommended** for an AI-driven translation workflow.
4+
5+
---
6+
7+
## Why Plan B wins when translations are AI-generated
8+
9+
When a new slug is added and AI generates the translations automatically, the
10+
pipeline becomes:
11+
12+
```
13+
New English slug → AI prompt → Translated JSON file → Commit to repo
14+
```
15+
16+
### Plan A (overlay) is awkward for AI
17+
18+
- AI must know *which fields to include* in the overlay and which to omit
19+
(`oldCode`, `modernCode`, `docs`, `related`, `prev`, `next` must all be
20+
absent).
21+
- If the AI accidentally includes any of those fields the build silently uses
22+
the AI value instead of the canonical English one — hard to detect.
23+
- Prompt engineering must explicitly say "only output these seven fields":
24+
`title`, `summary`, `explanation`, `oldApproach`, `modernApproach`,
25+
`whyModernWins`, `support.description`.
26+
- The overlay schema is a non-standard concept; every new contributor (human
27+
or AI) needs to learn it.
28+
29+
### Plan B (full replacement) is ideal for AI
30+
31+
- AI receives the full English JSON and outputs a complete translated JSON.
32+
No special field-filtering rules.
33+
- `oldCode` and `modernCode` are simply copied verbatim from the English file
34+
at build time, regardless of what the AI wrote — the generator always
35+
overwrites them. Zero prompt-engineering required to handle this case.
36+
- The output is **self-contained and trivially validatable**: run the same JSON
37+
schema checks as for English files.
38+
- The fallback mechanism is explicit: if the AI-generated file does not yet
39+
exist, the generator falls back to English and can display an "untranslated"
40+
banner — a clear signal rather than a silent gap.
41+
- `translations/strings/{locale}.json` (UI strings) is a simple key-value
42+
file; AI can translate it in one shot with minimal instructions.
43+
44+
---
45+
46+
## Recommended AI automation workflow
47+
48+
1. **Trigger**: GitHub Actions detects a new `content/<cat>/<slug>.json` commit
49+
(or a workflow dispatch).
50+
2. **AI step**: For each supported locale, call the translation AI with a
51+
structured prompt:
52+
```
53+
Translate the following Java pattern JSON from English to {locale}.
54+
- Keep slug, id, category, difficulty, jdkVersion, oldLabel, modernLabel,
55+
oldCode, modernCode, docs, related, prev, next, support.state unchanged.
56+
- Translate: title, summary, explanation, oldApproach, modernApproach,
57+
whyModernWins[*].title, whyModernWins[*].desc, support.description.
58+
- Return valid JSON only.
59+
```
60+
3. **Validate**: Run the same JSON schema validation used for English files.
61+
4. **Write**: Commit the translated file to
62+
`translations/content/{locale}/<cat>/<slug>.json`.
63+
5. **Build**: The generator picks it up on the next deployment and removes the
64+
"untranslated" banner automatically.
65+
66+
> **Note**: Even though Plan B asks translators to provide `oldCode` and
67+
> `modernCode`, the build tooling always overwrites those fields with the
68+
> English values. So AI can safely copy them verbatim — no risk of translated
69+
> or hallucinated code leaking into the site.
70+
71+
---
72+
73+
## Addressing Plan B's main risk
74+
75+
Plan B's biggest concern is keeping translated content files in sync when the
76+
English original changes (e.g. a corrected explanation). The AI workflow
77+
mitigates this:
78+
79+
- When a `content/<cat>/<slug>.json` file is **modified**, the same automation
80+
can regenerate the translated file, or flag the diff for human review.
81+
- A simple CI check can compare the `jdkVersion`, `id`, and `slug` in the
82+
English file with the translated file to catch stale translations.
83+
84+
---
85+
86+
## Summary
87+
88+
| Criterion | Plan A | Plan B |
89+
|---|---|---|
90+
| AI prompt complexity | Higher (must specify excluded fields) | Lower (translate whole file; build ignores code fields) |
91+
| Risk of AI error slipping through | Higher (wrong field inclusion is silent) | Lower (code fields are always overwritten) |
92+
| Validation of AI output | Schema + overlay semantics | Schema only |
93+
| Fallback visibility | Silent (English shown without notice) | Explicit banner |
94+
| Human translator experience | Must understand overlay contract | Self-contained file |
95+
| **Overall for AI workflow** | ⚠️ Workable but fragile | ✅ Recommended |

0 commit comments

Comments
 (0)