sisyo 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +16 -16
  2. package/README.md +177 -166
  3. package/bin/known-hashes.json +8 -1
  4. package/bin/sisyo.js +285 -285
  5. package/package.json +30 -30
  6. package/templates/.claude/rules/agents-and-tests.md +32 -24
  7. package/templates/.claude/rules/docs.md +39 -19
  8. package/templates/.claude/skills/fastapi-best-practices/ASYNC-PATTERNS.md +121 -121
  9. package/templates/.claude/skills/fastapi-best-practices/DATABASE.md +153 -153
  10. package/templates/.claude/skills/fastapi-best-practices/DEPENDENCIES.md +140 -140
  11. package/templates/.claude/skills/fastapi-best-practices/PROJECT-STRUCTURE.md +90 -90
  12. package/templates/.claude/skills/fastapi-best-practices/PYDANTIC-GUIDE.md +155 -155
  13. package/templates/.claude/skills/fastapi-best-practices/SKILL.md +123 -123
  14. package/templates/.claude/skills/g6-style/SKILL.md +125 -125
  15. package/templates/.claude/skills/g6-style/references/checks.md +58 -58
  16. package/templates/.claude/skills/g6-style/references/imagery.md +103 -103
  17. package/templates/.claude/skills/g6-style/references/motion.md +121 -121
  18. package/templates/.claude/skills/g6-style/references/sections.md +263 -263
  19. package/templates/.claude/skills/g6-style/references/tokens.md +197 -197
  20. package/templates/.claude/skills/hindsight/SKILL.md +175 -175
  21. package/templates/.claude/skills/hoang-auth/SKILL.md +188 -0
  22. package/templates/.claude/skills/html-docs/SKILL.md +207 -207
  23. package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -153
  24. package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -47
  25. package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -46
  26. package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -17
  27. package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -6
  28. package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -4
  29. package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -6
  30. package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -22
  31. package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -10
  32. package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -5
  33. package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -20
  34. package/templates/.claude/skills/i18n-multilang/references/format.md +100 -100
  35. package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -97
  36. package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -256
  37. package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -161
  38. package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -142
  39. package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -107
  40. package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -143
  41. package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -271
  42. package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -1041
  43. package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -1013
  44. package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -478
  45. package/templates/.claude/skills/neon-game-ui-ux-skill/COMPONENTS.md +490 -490
  46. package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -246
  47. package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -249
  48. package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -362
  49. package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -168
  50. package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -137
  51. package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -323
  52. package/templates/.claude/skills/react-page-oriented/SKILL.md +407 -407
  53. package/templates/.claude/skills/react-page-oriented/triggers.md +12 -12
  54. package/templates/.claude/skills/terraform-best-practices/SKILL.md +341 -341
  55. package/templates/.claude/skills/typesafe-jev/SKILL.md +148 -148
  56. package/templates/.claude/skills/vibe-docs/SKILL.md +139 -242
  57. package/templates/SISYO.md +39 -37
  58. package/templates/docs/99_progress/features.md +7 -7
  59. package/templates/docs/99_progress/handoff.md +19 -19
  60. package/templates/docs/99_progress/todo.md +15 -15
  61. package/templates/docs/MAP.md +26 -26
@@ -1,256 +1,256 @@
1
- # Layout, versions, delivery
2
-
3
- ## Contents
4
- 1. Folder layout in a repository
5
- 2. `i18n.config.json`
6
- 3. What goes in git, what goes to S3
7
- 4. Versions: `version`, `revision`, `compat`
8
- 5. The pack and the manifest
9
- 6. Delivery: bundled, CDN, or both
10
- 7. CDN layout and cache rules (S3 + CloudFront)
11
- 8. Publishing
12
- 9. How an app picks and updates a pack
13
-
14
- ## 1. Folder layout
15
-
16
- One `i18n/` folder per product, at the repository root (a monorepo may put it next to the client). Engine folders
17
- only receive **copies** made by `pack`.
18
-
19
- ```
20
- i18n/
21
- i18n.config.json the project's settings (section 2)
22
- .gitattributes LF line ends for everything here; audio marked binary
23
- .gitignore dist/ and voice/_audio/
24
- README.md what this folder is, for people and agents without the skill
25
- style.md audience, tone, per-language rules: the translator's brief
26
- glossary.json names to keep, fixed terms, forbidden words
27
- locales/<lang>/<ns>.json the texts; <sourceLanguage> is written by authors, the rest by "apply"
28
- notes/<ns>.json context and length limits per key
29
- meta/<lang>.json which source text each translation was made from; locked keys (tool-owned)
30
- manifest.json versions and hashes of the last pack (tool-owned)
31
- voice/ only in a product with voice
32
- speak/<lang>.json spoken-text overrides, written with "voice.py say": {"ns:key": {"text": …, "speak": …}}
33
- <lang>/manifest.json every clip: spoken text, hashes, voice, date (tool-owned)
34
- manifest.json versions and hashes of the last voice pack (tool-owned)
35
- _audio/ local cache of clips (not in git)
36
- dist/ pack output + upload plans (not in git)
37
- ```
38
-
39
- An existing project may keep its texts where they are: `localesDir` and `layout` point at them
40
- (`"layout": "{lang}.json"` for one file per language). New projects use the default.
41
-
42
- ## 2. `i18n.config.json`
43
-
44
- ```json
45
- {
46
- "schema": 1,
47
- "product": "mygame",
48
- "sourceLanguage": "vi",
49
- "referenceLanguage": "en",
50
- "compat": 1,
51
- "localesDir": "locales",
52
- "layout": "{lang}/{ns}.json",
53
- "languages": "default",
54
- "exclude": [],
55
- "capabilities": [],
56
- "bundle": { "languages": "all", "copyTo": ["../Assets/StreamingAssets/i18n"] },
57
- "dist": "dist",
58
- "cdn": { "baseUrl": "https://cdn.example.com", "textPrefix": "i18n", "voicePrefix": "voice" },
59
- "voice": {
60
- "languages": ["vi", "en", "ja"],
61
- "fallback": "en",
62
- "sets": { "common": {"include": ["voice:*"]}, "chapter01": {"include": ["chapter01:*"], "exclude": ["chapter01:*.title"]} },
63
- "voicePattern": "Narrator-{lang}",
64
- "numberStyle": { "vi": {"four": "tư"} },
65
- "format": "mp3"
66
- }
67
- }
68
- ```
69
-
70
- | Field | Meaning |
71
- |---|---|
72
- | `sourceLanguage` | the language texts are written in first (the language the team writes in: `vi`, `en`, …) |
73
- | `referenceLanguage` | a second language shown to the translator next to the source (default `en`). Translate it first |
74
- | `compat` | the pack format generation (section 4). Starts at 1 and almost never changes |
75
- | `languages` | `"default"` = the 40 languages of the registry, or a list of codes. `exclude` removes some |
76
- | `capabilities` | what the product's text renderer can do: `"rtl"`, `"shaping"`. A language that needs one that is not declared is `blocked` and never packed ([languages.md](languages.md)) |
77
- | `bundle.copyTo` | folders (relative to `i18n/`) that receive `<lang>.json` + `manifest.json` at every `pack`: the copy shipped inside the app |
78
- | `bundle.languages` | `"all"` (default: text packs are tiny) or a list |
79
- | `cdn` | where packs are served from; the prefixes are the first path segments on the CDN |
80
- | `voice` | **optional: leave the whole block out for a text-only product** (most are). Off while `languages` or `sets` is empty. See [voice.md](voice.md) |
81
-
82
- ## 3. Git or S3
83
-
84
- | In git | Not in git |
85
- |---|---|
86
- | everything under `i18n/` except `dist/` and `voice/_audio/`: source texts, **all translations**, notes, glossary, meta, manifests, spoken-text overrides | audio clips (S3 / CDN), built packs (`dist/`), Addressables bundles, video |
87
-
88
- Why: 40 languages of text are a few MB and diff well, so the repository stays the single source of truth for words.
89
- Audio is binary, grows with every regeneration and fills Git LFS (GitHub's free plan: 10 GiB of storage and of
90
- bandwidth a month); S3 is versioned and cheap. The clip manifests in git record each clip's SHA-256, so the repository
91
- still says exactly which audio belongs to which commit.
92
-
93
- The same repository holds code and texts: they change together (a new feature = new keys), and one commit must
94
- contain both. Do not split texts into a separate repository.
95
-
96
- Line ends: the tools write LF. On Windows with `core.autocrlf` git would turn them into CRLF at the next checkout,
97
- so `init` puts a `.gitattributes` (`* text=auto eol=lf`) in `i18n/`; a project that adopts the standard by hand adds
98
- the same file. The bundle copies of the packs are a single line with no line end, so their hashes are the same on
99
- every machine wherever they are copied.
100
-
101
- ## 4. Versions
102
-
103
- | Number | Scope | Changes when | Used for |
104
- |---|---|---|---|
105
- | text `version` (integer) | one language's text pack | its content hash changed at `i18n.py pack` | an app compares the bundled and the downloaded copy: **the higher version wins** |
106
- | voice `version` (integer) | one voice set of one language (only in a product with voice) | its clips, or the texts they are accepted for, changed at `voice.py pack` | the app re-reads the set's index and fetches the clips that changed |
107
- | `textVersion` | a voice language | every `voice.py pack` | says which text version the voice sets were packed for: text may be ahead of voice |
108
- | `revision` (integer) | the whole manifest | anything in it changed | cheap "is there anything new" check; logging |
109
- | `compat` (integer) | the product's packs | the pack format or the key scheme changes so that already-shipped apps could not read new packs | the CDN path (`i18n/c1/…`): old apps keep reading their own folder |
110
- | `hash` (SHA-256) | every file | content | names on the CDN, integrity check after download |
111
-
112
- Rules:
113
- - **Only `pack` writes versions.** Never edit `manifest.json` by hand. After a merge conflict in it, take the higher
114
- numbers and run `pack` again.
115
- - **Versions only go up.** To undo a bad translation, fix the text and pack again (roll forward). An app never
116
- replaces a pack by a lower version.
117
- - **Within one `compat`, never change what an existing key means or which placeholders it takes.** An app released
118
- last month will download today's pack and call that key with last month's values. A different meaning is a new key
119
- ([format.md](format.md)).
120
- - **Removing a key is safe when every text language is bundled** (the default): an old app that still uses the key
121
- finds it in its own bundled pack, which stays the floor under any downloaded pack. If a product bundles only some
122
- languages, keep a key until no supported app version uses it.
123
- - **Text and voice have separate versions.** A text change never forces a voice download, and voice can lag: the
124
- voice manifest records the text version it was packed for and, per set, how many lines are `behind` (the text
125
- changed, the old clip still plays) or `silent`. `python i18n.py versions` prints both sides per language
126
- ([voice.md](voice.md) §5).
127
- - **Bump `compat` only for a break**: a new pack schema, a mass key rename, a placeholder syntax change. Then versions
128
- restart at 1 in the new `c<N>` folder and the old folder is left in place for old apps.
129
-
130
- ## 5. The pack and the manifest
131
-
132
- `python i18n.py pack` builds, for every language that has translations and is not blocked:
133
-
134
- - `dist/i18n/c<compat>/<lang>/<lang>.<hash12>.json`: one file per language, all namespaces, **flat keys**:
135
-
136
- ```json
137
- {"schema":1,"lang":"ja","strings":{"common":{"action.ok":"OK"},"shop":{"items_other":"{{count}}こ","title":"ショップ"}}}
138
- ```
139
-
140
- Only texts that are translated **and up to date** are in it. A missing or stale text is left out, so the runtime
141
- falls back for that key instead of showing a sentence that no longer matches.
142
- - `dist/i18n/c<compat>/manifest.json` and the same file as `i18n/manifest.json` (committed):
143
-
144
- ```json
145
- {
146
- "schema": 1, "product": "mygame", "compat": 1, "revision": 7, "updatedAt": "2026-11-13T09:38:03Z",
147
- "sourceLanguage": "vi", "fallbackLanguage": "en", "texts": 1416,
148
- "languages": {
149
- "ja": { "name": "Japanese", "native": "日本語", "dir": "ltr", "script": "Jpan",
150
- "version": 5, "hash": "<sha256>", "file": "ja/ja.3f2a9c1b77d0.json", "bytes": 151234,
151
- "texts": 1416, "coverage": 1.0, "status": "ready", "fallback": ["en", "vi"] }
152
- }
153
- }
154
- ```
155
-
156
- `status` is `ready` (every text translated and current) or `partial`. `aliases` lists device locale codes that map
157
- to the language. The manifest is all a runtime needs: names for the picker, matching, fallback order, file, hash.
158
- - The bundle copies in every `bundle.copyTo` folder: `<lang>.json` (stable names, so engine meta files do not churn)
159
- and a `manifest.json` whose `file` fields point at them. Same bytes, same hash, same version as the CDN files.
160
- - `dist/upload-plan.text.json`: every file with its CDN key, content type and cache header, the manifest last.
161
-
162
- `pack` refuses to run when `check` has errors, and when a language that was `ready` in the last pack no longer is
163
- (a feature added texts that nobody translated). Translate, then pack. `--allow-regress` exists for the owner's
164
- explicit decision to ship without a language.
165
-
166
- Voice sets are packed the same way by `voice.py pack` ([voice.md](voice.md)).
167
-
168
- ## 6. Delivery modes
169
-
170
- | Mode | When | How |
171
- |---|---|---|
172
- | **Bundled** | always for text in games and apps; websites that import JSON at build | `bundle.copyTo` → the app reads its own copy; works offline from the first second |
173
- | **CDN** | to fix or add translations without a store release; to add languages later; voice | upload `dist/` to the product's bucket; the app checks the manifest |
174
- | **Both** (default for games and apps) | text | bundled pack = floor, CDN pack = update. Higher `version` wins per language |
175
-
176
- Text packs are about 25–45 KB per language compressed, so bundling all of them costs about 1–2 MB and removes the
177
- "first launch without network shows the wrong language" problem. Voice is never bundled by default: it is downloaded
178
- per set when first needed (lazy), because it is 2–14 MB per language.
179
-
180
- Apple guideline 4.2.3: if the app downloads something sizeable (voice sets, chapters), show the size and ask first.
181
- Packs are data, never code: nothing in a pack is executed.
182
-
183
- ## 7. CDN layout and cache rules
184
-
185
- One bucket + CloudFront distribution per product (a custom domain → CloudFront → a private S3 bucket, defined in the
186
- product's Terraform). The address below is written `cdn.<your-domain>`; the real one is the project's `cdn.baseUrl`.
187
-
188
- ```
189
- https://cdn.<your-domain>/
190
- i18n/c1/manifest.json Cache-Control: public, max-age=60
191
- i18n/c1/<lang>/<lang>.<hash12>.json public, max-age=31536000, immutable
192
- voice/c1/manifest.json public, max-age=60
193
- voice/c1/<lang>/<set>.<hash12>.json immutable (index of a voice set: line id -> clip file)
194
- voice/clips/<lang>/<sha16>.<ext> immutable (one clip; named by its content, shared by every version)
195
- ```
196
-
197
- - Everything except the two manifests has its hash in its name and never changes, so it is cached for a year. A new
198
- version is a new file name. This is what makes updates safe: the manifest switches in one step.
199
- - Clips are content-addressed and live outside `c<compat>`: a set's new version re-downloads only the clips that
200
- changed, and a `compat` bump re-uploads nothing.
201
- - S3 stays private (CloudFront OAC). Never let apps download from the bucket URL: S3 egress costs about $0.09/GB.
202
- - **Infra to check once per product** (Terraform, owner applies): the bucket policy must let the CDN read the
203
- `i18n/*` and `voice/*` prefixes, and the short-TTL cache behaviour must match only `*/manifest.json` there. If
204
- the distribution already serves other content and gives every `*.json` a short TTL, add behaviours for
205
- `i18n/*/manifest.json` and `voice/*/manifest.json` (short) ahead of `i18n/*` and `voice/*` (immutable), so the
206
- hashed pack files are cached for a year. An agent writes the change and runs `plan`; applying is the owner's step.
207
- - Optional private prefix `voice-master/<lang>/…` (not served) for the lossless WAV takes.
208
-
209
- ## 8. Publishing
210
-
211
- Publishing changes what real users see, so it is a deliberate step, not part of `pack`.
212
-
213
- 1. `i18n.py check`, `i18n.py pack` and, for a product with voice, `voice.py pack` on the commit that will be
214
- released. Commit the manifests. If `voice.py pack` reports lines that will be silent (their text changed and the
215
- new clips do not exist yet), stop: publishing the text now or waiting for the clips is the owner's decision
216
- ([voice.md](voice.md)). Voice files go up before the text manifest.
217
- 2. Upload from `dist/` in the order of the upload plan: **every hashed file first, the manifest last**. If the upload
218
- stops halfway, the old manifest still points at complete old files.
219
-
220
- ```bash
221
- aws s3 cp dist/i18n/c1/ s3://<bucket>/i18n/c1/ --recursive --exclude manifest.json \
222
- --cache-control "public, max-age=31536000, immutable" --content-type "application/json; charset=utf-8"
223
- aws s3 cp dist/i18n/c1/manifest.json s3://<bucket>/i18n/c1/manifest.json \
224
- --cache-control "public, max-age=60" --content-type "application/json; charset=utf-8"
225
- ```
226
-
227
- A product with its own deploy script extends that script to read the upload plans instead of hand-running `aws`.
228
- 3. Verify from outside: fetch `<baseUrl>/i18n/c1/manifest.json`, then one pack file, and compare its SHA-256 with the
229
- manifest.
230
- 4. No CloudFront invalidation is needed: the manifest expires in 60 s and nothing else is ever overwritten.
231
-
232
- Who runs it: a person, or the lead agent by hand, after the owner has approved publishing for that product; never a
233
- background sub-agent. The first publish of a product, any Terraform apply and any change to bucket policy wait for
234
- the owner.
235
-
236
- Additive changes (new keys, better translations, a new language) can be published at any time: old apps ignore keys
237
- they do not use. Publish them **before or together with** the app release that needs them; an app whose bundled pack
238
- is newer than the CDN simply keeps its bundled pack.
239
-
240
- ## 9. How an app picks and updates a pack
241
-
242
- The contract every runtime implements ([platform-unity.md](platform-unity.md), [platform-web.md](platform-web.md)):
243
-
244
- 1. At start, read the bundled `manifest.json` and any previously downloaded manifest from the app's data folder
245
- (`<persistent>/i18n/c<compat>/`).
246
- 2. For the active language, load the copy with the **higher `version`** (downloaded or bundled). Keep the bundled pack
247
- loaded underneath it for keys the downloaded one lacks.
248
- 3. In the background (at most once per launch, never blocking the first screen), fetch the CDN manifest. For the
249
- active language and any language the user downloaded before: if the CDN `version` is higher, download the file,
250
- check its SHA-256 against the manifest, write it to a temporary name, then rename it into place. Apply it at the
251
- next language load (or raise the language-changed event).
252
- 4. A language that is not bundled is downloaded when the user picks it; show progress and keep the old language until
253
- the new pack is verified.
254
- 5. Any failure (offline, wrong hash, bad JSON) leaves the current pack untouched. Never show an empty UI.
255
- 6. Lookup order for a key: active language (downloaded over bundled) → the language's `fallback` list → the source
256
- language → the key itself (and a log line in development builds).
1
+ # Layout, versions, delivery
2
+
3
+ ## Contents
4
+ 1. Folder layout in a repository
5
+ 2. `i18n.config.json`
6
+ 3. What goes in git, what goes to S3
7
+ 4. Versions: `version`, `revision`, `compat`
8
+ 5. The pack and the manifest
9
+ 6. Delivery: bundled, CDN, or both
10
+ 7. CDN layout and cache rules (S3 + CloudFront)
11
+ 8. Publishing
12
+ 9. How an app picks and updates a pack
13
+
14
+ ## 1. Folder layout
15
+
16
+ One `i18n/` folder per product, at the repository root (a monorepo may put it next to the client). Engine folders
17
+ only receive **copies** made by `pack`.
18
+
19
+ ```
20
+ i18n/
21
+ i18n.config.json the project's settings (section 2)
22
+ .gitattributes LF line ends for everything here; audio marked binary
23
+ .gitignore dist/ and voice/_audio/
24
+ README.md what this folder is, for people and agents without the skill
25
+ style.md audience, tone, per-language rules: the translator's brief
26
+ glossary.json names to keep, fixed terms, forbidden words
27
+ locales/<lang>/<ns>.json the texts; <sourceLanguage> is written by authors, the rest by "apply"
28
+ notes/<ns>.json context and length limits per key
29
+ meta/<lang>.json which source text each translation was made from; locked keys (tool-owned)
30
+ manifest.json versions and hashes of the last pack (tool-owned)
31
+ voice/ only in a product with voice
32
+ speak/<lang>.json spoken-text overrides, written with "voice.py say": {"ns:key": {"text": …, "speak": …}}
33
+ <lang>/manifest.json every clip: spoken text, hashes, voice, date (tool-owned)
34
+ manifest.json versions and hashes of the last voice pack (tool-owned)
35
+ _audio/ local cache of clips (not in git)
36
+ dist/ pack output + upload plans (not in git)
37
+ ```
38
+
39
+ An existing project may keep its texts where they are: `localesDir` and `layout` point at them
40
+ (`"layout": "{lang}.json"` for one file per language). New projects use the default.
41
+
42
+ ## 2. `i18n.config.json`
43
+
44
+ ```json
45
+ {
46
+ "schema": 1,
47
+ "product": "mygame",
48
+ "sourceLanguage": "vi",
49
+ "referenceLanguage": "en",
50
+ "compat": 1,
51
+ "localesDir": "locales",
52
+ "layout": "{lang}/{ns}.json",
53
+ "languages": "default",
54
+ "exclude": [],
55
+ "capabilities": [],
56
+ "bundle": { "languages": "all", "copyTo": ["../Assets/StreamingAssets/i18n"] },
57
+ "dist": "dist",
58
+ "cdn": { "baseUrl": "https://cdn.example.com", "textPrefix": "i18n", "voicePrefix": "voice" },
59
+ "voice": {
60
+ "languages": ["vi", "en", "ja"],
61
+ "fallback": "en",
62
+ "sets": { "common": {"include": ["voice:*"]}, "chapter01": {"include": ["chapter01:*"], "exclude": ["chapter01:*.title"]} },
63
+ "voicePattern": "Narrator-{lang}",
64
+ "numberStyle": { "vi": {"four": "tư"} },
65
+ "format": "mp3"
66
+ }
67
+ }
68
+ ```
69
+
70
+ | Field | Meaning |
71
+ |---|---|
72
+ | `sourceLanguage` | the language texts are written in first (the language the team writes in: `vi`, `en`, …) |
73
+ | `referenceLanguage` | a second language shown to the translator next to the source (default `en`). Translate it first |
74
+ | `compat` | the pack format generation (section 4). Starts at 1 and almost never changes |
75
+ | `languages` | `"default"` = the 40 languages of the registry, or a list of codes. `exclude` removes some |
76
+ | `capabilities` | what the product's text renderer can do: `"rtl"`, `"shaping"`. A language that needs one that is not declared is `blocked` and never packed ([languages.md](languages.md)) |
77
+ | `bundle.copyTo` | folders (relative to `i18n/`) that receive `<lang>.json` + `manifest.json` at every `pack`: the copy shipped inside the app |
78
+ | `bundle.languages` | `"all"` (default: text packs are tiny) or a list |
79
+ | `cdn` | where packs are served from; the prefixes are the first path segments on the CDN |
80
+ | `voice` | **optional: leave the whole block out for a text-only product** (most are). Off while `languages` or `sets` is empty. See [voice.md](voice.md) |
81
+
82
+ ## 3. Git or S3
83
+
84
+ | In git | Not in git |
85
+ |---|---|
86
+ | everything under `i18n/` except `dist/` and `voice/_audio/`: source texts, **all translations**, notes, glossary, meta, manifests, spoken-text overrides | audio clips (S3 / CDN), built packs (`dist/`), Addressables bundles, video |
87
+
88
+ Why: 40 languages of text are a few MB and diff well, so the repository stays the single source of truth for words.
89
+ Audio is binary, grows with every regeneration and fills Git LFS (GitHub's free plan: 10 GiB of storage and of
90
+ bandwidth a month); S3 is versioned and cheap. The clip manifests in git record each clip's SHA-256, so the repository
91
+ still says exactly which audio belongs to which commit.
92
+
93
+ The same repository holds code and texts: they change together (a new feature = new keys), and one commit must
94
+ contain both. Do not split texts into a separate repository.
95
+
96
+ Line ends: the tools write LF. On Windows with `core.autocrlf` git would turn them into CRLF at the next checkout,
97
+ so `init` puts a `.gitattributes` (`* text=auto eol=lf`) in `i18n/`; a project that adopts the standard by hand adds
98
+ the same file. The bundle copies of the packs are a single line with no line end, so their hashes are the same on
99
+ every machine wherever they are copied.
100
+
101
+ ## 4. Versions
102
+
103
+ | Number | Scope | Changes when | Used for |
104
+ |---|---|---|---|
105
+ | text `version` (integer) | one language's text pack | its content hash changed at `i18n.py pack` | an app compares the bundled and the downloaded copy: **the higher version wins** |
106
+ | voice `version` (integer) | one voice set of one language (only in a product with voice) | its clips, or the texts they are accepted for, changed at `voice.py pack` | the app re-reads the set's index and fetches the clips that changed |
107
+ | `textVersion` | a voice language | every `voice.py pack` | says which text version the voice sets were packed for: text may be ahead of voice |
108
+ | `revision` (integer) | the whole manifest | anything in it changed | cheap "is there anything new" check; logging |
109
+ | `compat` (integer) | the product's packs | the pack format or the key scheme changes so that already-shipped apps could not read new packs | the CDN path (`i18n/c1/…`): old apps keep reading their own folder |
110
+ | `hash` (SHA-256) | every file | content | names on the CDN, integrity check after download |
111
+
112
+ Rules:
113
+ - **Only `pack` writes versions.** Never edit `manifest.json` by hand. After a merge conflict in it, take the higher
114
+ numbers and run `pack` again.
115
+ - **Versions only go up.** To undo a bad translation, fix the text and pack again (roll forward). An app never
116
+ replaces a pack by a lower version.
117
+ - **Within one `compat`, never change what an existing key means or which placeholders it takes.** An app released
118
+ last month will download today's pack and call that key with last month's values. A different meaning is a new key
119
+ ([format.md](format.md)).
120
+ - **Removing a key is safe when every text language is bundled** (the default): an old app that still uses the key
121
+ finds it in its own bundled pack, which stays the floor under any downloaded pack. If a product bundles only some
122
+ languages, keep a key until no supported app version uses it.
123
+ - **Text and voice have separate versions.** A text change never forces a voice download, and voice can lag: the
124
+ voice manifest records the text version it was packed for and, per set, how many lines are `behind` (the text
125
+ changed, the old clip still plays) or `silent`. `python i18n.py versions` prints both sides per language
126
+ ([voice.md](voice.md) §5).
127
+ - **Bump `compat` only for a break**: a new pack schema, a mass key rename, a placeholder syntax change. Then versions
128
+ restart at 1 in the new `c<N>` folder and the old folder is left in place for old apps.
129
+
130
+ ## 5. The pack and the manifest
131
+
132
+ `python i18n.py pack` builds, for every language that has translations and is not blocked:
133
+
134
+ - `dist/i18n/c<compat>/<lang>/<lang>.<hash12>.json`: one file per language, all namespaces, **flat keys**:
135
+
136
+ ```json
137
+ {"schema":1,"lang":"ja","strings":{"common":{"action.ok":"OK"},"shop":{"items_other":"{{count}}こ","title":"ショップ"}}}
138
+ ```
139
+
140
+ Only texts that are translated **and up to date** are in it. A missing or stale text is left out, so the runtime
141
+ falls back for that key instead of showing a sentence that no longer matches.
142
+ - `dist/i18n/c<compat>/manifest.json` and the same file as `i18n/manifest.json` (committed):
143
+
144
+ ```json
145
+ {
146
+ "schema": 1, "product": "mygame", "compat": 1, "revision": 7, "updatedAt": "2026-11-13T09:38:03Z",
147
+ "sourceLanguage": "vi", "fallbackLanguage": "en", "texts": 1416,
148
+ "languages": {
149
+ "ja": { "name": "Japanese", "native": "日本語", "dir": "ltr", "script": "Jpan",
150
+ "version": 5, "hash": "<sha256>", "file": "ja/ja.3f2a9c1b77d0.json", "bytes": 151234,
151
+ "texts": 1416, "coverage": 1.0, "status": "ready", "fallback": ["en", "vi"] }
152
+ }
153
+ }
154
+ ```
155
+
156
+ `status` is `ready` (every text translated and current) or `partial`. `aliases` lists device locale codes that map
157
+ to the language. The manifest is all a runtime needs: names for the picker, matching, fallback order, file, hash.
158
+ - The bundle copies in every `bundle.copyTo` folder: `<lang>.json` (stable names, so engine meta files do not churn)
159
+ and a `manifest.json` whose `file` fields point at them. Same bytes, same hash, same version as the CDN files.
160
+ - `dist/upload-plan.text.json`: every file with its CDN key, content type and cache header, the manifest last.
161
+
162
+ `pack` refuses to run when `check` has errors, and when a language that was `ready` in the last pack no longer is
163
+ (a feature added texts that nobody translated). Translate, then pack. `--allow-regress` exists for the owner's
164
+ explicit decision to ship without a language.
165
+
166
+ Voice sets are packed the same way by `voice.py pack` ([voice.md](voice.md)).
167
+
168
+ ## 6. Delivery modes
169
+
170
+ | Mode | When | How |
171
+ |---|---|---|
172
+ | **Bundled** | always for text in games and apps; websites that import JSON at build | `bundle.copyTo` → the app reads its own copy; works offline from the first second |
173
+ | **CDN** | to fix or add translations without a store release; to add languages later; voice | upload `dist/` to the product's bucket; the app checks the manifest |
174
+ | **Both** (default for games and apps) | text | bundled pack = floor, CDN pack = update. Higher `version` wins per language |
175
+
176
+ Text packs are about 25–45 KB per language compressed, so bundling all of them costs about 1–2 MB and removes the
177
+ "first launch without network shows the wrong language" problem. Voice is never bundled by default: it is downloaded
178
+ per set when first needed (lazy), because it is 2–14 MB per language.
179
+
180
+ Apple guideline 4.2.3: if the app downloads something sizeable (voice sets, chapters), show the size and ask first.
181
+ Packs are data, never code: nothing in a pack is executed.
182
+
183
+ ## 7. CDN layout and cache rules
184
+
185
+ One bucket + CloudFront distribution per product (a custom domain → CloudFront → a private S3 bucket, defined in the
186
+ product's Terraform). The address below is written `cdn.<your-domain>`; the real one is the project's `cdn.baseUrl`.
187
+
188
+ ```
189
+ https://cdn.<your-domain>/
190
+ i18n/c1/manifest.json Cache-Control: public, max-age=60
191
+ i18n/c1/<lang>/<lang>.<hash12>.json public, max-age=31536000, immutable
192
+ voice/c1/manifest.json public, max-age=60
193
+ voice/c1/<lang>/<set>.<hash12>.json immutable (index of a voice set: line id -> clip file)
194
+ voice/clips/<lang>/<sha16>.<ext> immutable (one clip; named by its content, shared by every version)
195
+ ```
196
+
197
+ - Everything except the two manifests has its hash in its name and never changes, so it is cached for a year. A new
198
+ version is a new file name. This is what makes updates safe: the manifest switches in one step.
199
+ - Clips are content-addressed and live outside `c<compat>`: a set's new version re-downloads only the clips that
200
+ changed, and a `compat` bump re-uploads nothing.
201
+ - S3 stays private (CloudFront OAC). Never let apps download from the bucket URL: S3 egress costs about $0.09/GB.
202
+ - **Infra to check once per product** (Terraform, owner applies): the bucket policy must let the CDN read the
203
+ `i18n/*` and `voice/*` prefixes, and the short-TTL cache behaviour must match only `*/manifest.json` there. If
204
+ the distribution already serves other content and gives every `*.json` a short TTL, add behaviours for
205
+ `i18n/*/manifest.json` and `voice/*/manifest.json` (short) ahead of `i18n/*` and `voice/*` (immutable), so the
206
+ hashed pack files are cached for a year. An agent writes the change and runs `plan`; applying is the owner's step.
207
+ - Optional private prefix `voice-master/<lang>/…` (not served) for the lossless WAV takes.
208
+
209
+ ## 8. Publishing
210
+
211
+ Publishing changes what real users see, so it is a deliberate step, not part of `pack`.
212
+
213
+ 1. `i18n.py check`, `i18n.py pack` and, for a product with voice, `voice.py pack` on the commit that will be
214
+ released. Commit the manifests. If `voice.py pack` reports lines that will be silent (their text changed and the
215
+ new clips do not exist yet), stop: publishing the text now or waiting for the clips is the owner's decision
216
+ ([voice.md](voice.md)). Voice files go up before the text manifest.
217
+ 2. Upload from `dist/` in the order of the upload plan: **every hashed file first, the manifest last**. If the upload
218
+ stops halfway, the old manifest still points at complete old files.
219
+
220
+ ```bash
221
+ aws s3 cp dist/i18n/c1/ s3://<bucket>/i18n/c1/ --recursive --exclude manifest.json \
222
+ --cache-control "public, max-age=31536000, immutable" --content-type "application/json; charset=utf-8"
223
+ aws s3 cp dist/i18n/c1/manifest.json s3://<bucket>/i18n/c1/manifest.json \
224
+ --cache-control "public, max-age=60" --content-type "application/json; charset=utf-8"
225
+ ```
226
+
227
+ A product with its own deploy script extends that script to read the upload plans instead of hand-running `aws`.
228
+ 3. Verify from outside: fetch `<baseUrl>/i18n/c1/manifest.json`, then one pack file, and compare its SHA-256 with the
229
+ manifest.
230
+ 4. No CloudFront invalidation is needed: the manifest expires in 60 s and nothing else is ever overwritten.
231
+
232
+ Who runs it: a person, or the lead agent by hand, after the owner has approved publishing for that product; never a
233
+ background sub-agent. The first publish of a product, any Terraform apply and any change to bucket policy wait for
234
+ the owner.
235
+
236
+ Additive changes (new keys, better translations, a new language) can be published at any time: old apps ignore keys
237
+ they do not use. Publish them **before or together with** the app release that needs them; an app whose bundled pack
238
+ is newer than the CDN simply keeps its bundled pack.
239
+
240
+ ## 9. How an app picks and updates a pack
241
+
242
+ The contract every runtime implements ([platform-unity.md](platform-unity.md), [platform-web.md](platform-web.md)):
243
+
244
+ 1. At start, read the bundled `manifest.json` and any previously downloaded manifest from the app's data folder
245
+ (`<persistent>/i18n/c<compat>/`).
246
+ 2. For the active language, load the copy with the **higher `version`** (downloaded or bundled). Keep the bundled pack
247
+ loaded underneath it for keys the downloaded one lacks.
248
+ 3. In the background (at most once per launch, never blocking the first screen), fetch the CDN manifest. For the
249
+ active language and any language the user downloaded before: if the CDN `version` is higher, download the file,
250
+ check its SHA-256 against the manifest, write it to a temporary name, then rename it into place. Apply it at the
251
+ next language load (or raise the language-changed event).
252
+ 4. A language that is not bundled is downloaded when the user picks it; show progress and keep the old language until
253
+ the new pack is verified.
254
+ 5. Any failure (offline, wrong hash, bad JSON) leaves the current pack untouched. Never show an empty UI.
255
+ 6. Lookup order for a key: active language (downloaded over bundled) → the language's `fallback` list → the source
256
+ language → the key itself (and a log line in development builds).