You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i18n: partial translation files, difficultyDisplay, YAML support
- Translation files now contain only translatable fields (title, summary,
explanation, oldApproach, modernApproach, whyModernWins, support.description).
The generator overlays them onto the English base, preventing divergence.
- Add difficultyDisplay token: CSS class stays as enum value, display text
resolved from UI strings (difficulty.beginner/intermediate/advanced).
- Generator loadStrings and resolveSnippet now support .json/.yaml/.yml
translation files via findWithExtensions/readAuto helpers.
- Update i18n spec with field translation reference table and partial-file
approach.
- Trim existing pt-BR translation files to translatable fields only.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: specs/i18n/i18n-spec.md
+57-37Lines changed: 57 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,25 +197,50 @@ is purely informational and does **not** abort the build.
197
197
198
198
## Content Translation Files
199
199
200
-
Translated content files are **complete** copies of the English pattern JSON
201
-
with translatable fields rendered in the target language. This avoids
202
-
partial-merge edge cases and makes each file self-contained.
200
+
Translated content files are **partial** — they contain **only** the
201
+
translatable fields. The generator overlays them onto the English base at build
202
+
time. This prevents translators from diverging structural data (code,
203
+
navigation, metadata) from the English source of truth.
204
+
205
+
### Field Translation Reference
206
+
207
+
Every field in a slug definition file falls into one of three categories:
208
+
209
+
| Category | Fields | Rule |
210
+
|---|---|---|
211
+
|**Translate** (include in translation file) |`title`, `summary`, `explanation`, `oldApproach`, `modernApproach`, `whyModernWins` (full array), `support.description`| These are the **only** fields present in a translation file |
212
+
|**English source of truth** (never in translation file) |`id`, `slug`, `category`, `difficulty`, `jdkVersion`, `oldLabel`, `modernLabel`, `oldCode`, `modernCode`, `prev`, `next`, `related`, `docs`| Always taken from the English content file; any values in the translation file are ignored |
213
+
|**Translated via UI strings**|`difficulty`, `support.state`| Enum values stay in English; display names resolved from `translations/strings/{locale}.json` at build time |
214
+
215
+
**Why enum fields use UI strings instead of content translation:**
216
+
217
+
Fields like `difficulty` (`beginner`, `intermediate`, `advanced`) and
218
+
`support.state` (`available`, `preview`, `experimental`) are enum values used
219
+
programmatically as CSS classes, filter keys, and data attributes. Their
220
+
**display names** are resolved at build time from the UI strings layer:
"summary": "Crie listas imutáveis em uma expressão limpa.",
4
+
"title": "Criação de listas imutáveis",
5
+
"oldApproach": "Encapsulamento verboso",
15
6
"explanation": "List.of() cria uma lista verdadeiramente imutável — sem encapsulamento, sem cópia defensiva. Rejeita elementos nulos (null-hostile) e é estruturalmente imutável. O modo antigo exigia três chamadas aninhadas.",
16
7
"whyModernWins": [
17
8
{
@@ -31,24 +22,6 @@
31
22
}
32
23
],
33
24
"support": {
34
-
"state": "available",
35
25
"description": "Amplamente disponível desde o JDK 9 (setembro de 2017)"
"summary": "Uma linha substitui mais de 30 linhas de boilerplate para portadores de dados imutáveis.",
4
+
"title": "Records para classes de dados",
5
+
"oldApproach": "POJO verboso",
15
6
"explanation": "Records geram automaticamente o construtor, acessores (x(), y()), equals(), hashCode() e toString(). São imutáveis por design e ideais para DTOs, objetos de valor e pattern matching.",
16
7
"whyModernWins": [
17
8
{
@@ -31,24 +22,6 @@
31
22
}
32
23
],
33
24
"support": {
34
-
"state": "available",
35
25
"description": "Amplamente disponível desde o JDK 16 (março de 2021)"
0 commit comments