sisyo 1.6.8 → 1.8.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.
- package/LICENSE +16 -16
- package/README.md +167 -162
- package/bin/known-hashes.json +100 -7
- package/package.json +1 -1
- package/templates/.claude/rules/agents-and-tests.md +32 -0
- package/templates/.claude/rules/docs.md +19 -19
- package/templates/.claude/skills/fastapi-best-practices/ASYNC-PATTERNS.md +121 -121
- package/templates/.claude/skills/fastapi-best-practices/DATABASE.md +153 -153
- package/templates/.claude/skills/fastapi-best-practices/DEPENDENCIES.md +140 -140
- package/templates/.claude/skills/fastapi-best-practices/PROJECT-STRUCTURE.md +90 -90
- package/templates/.claude/skills/fastapi-best-practices/PYDANTIC-GUIDE.md +155 -155
- package/templates/.claude/skills/fastapi-best-practices/SKILL.md +123 -123
- package/templates/.claude/skills/g6-style/SKILL.md +125 -0
- package/templates/.claude/skills/g6-style/references/checks.md +58 -0
- package/templates/.claude/skills/g6-style/references/imagery.md +103 -0
- package/templates/.claude/skills/g6-style/references/motion.md +121 -0
- package/templates/.claude/skills/g6-style/references/sections.md +263 -0
- package/templates/.claude/skills/g6-style/references/tokens.md +197 -0
- package/templates/.claude/skills/hindsight/SKILL.md +175 -172
- package/templates/.claude/skills/hoang-auth/SKILL.md +188 -0
- package/templates/.claude/skills/html-docs/SKILL.md +207 -207
- package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -0
- package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -0
- package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -0
- package/templates/.claude/skills/i18n-multilang/references/format.md +100 -0
- package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -0
- package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -0
- package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -0
- package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -0
- package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -0
- package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -0
- package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -0
- package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -0
- package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -0
- package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -0
- package/templates/.claude/skills/react-page-oriented/SKILL.md +407 -407
- package/templates/.claude/skills/react-page-oriented/triggers.md +12 -12
- package/templates/.claude/skills/terraform-best-practices/SKILL.md +341 -341
- package/templates/.claude/skills/typesafe-jev/SKILL.md +148 -148
- package/templates/.claude/skills/vibe-docs/SKILL.md +242 -242
- package/templates/SISYO.md +37 -37
- package/templates/docs/99_progress/features.md +7 -7
- package/templates/docs/99_progress/handoff.md +19 -19
- package/templates/docs/99_progress/todo.md +15 -15
- package/templates/docs/MAP.md +26 -26
|
@@ -0,0 +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).
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Numbers in voice
|
|
2
|
+
|
|
3
|
+
> A typical report: "1234" is read "một, hai trăm ba mươi bốn" when it must be "một nghìn hai trăm ba mươi bốn";
|
|
4
|
+
> "105" must be "một trăm linh năm" or "một trăm lẻ năm", never "một trăm năm". Every language has its own version
|
|
5
|
+
> of this.
|
|
6
|
+
|
|
7
|
+
## Why it goes wrong
|
|
8
|
+
|
|
9
|
+
A TTS model reads characters, not quantities. Given `1234`, `1 234` or `1.234` it guesses, and the guess depends on
|
|
10
|
+
the language, the separator and the words around it. Even with the right words it can swallow the small ones when it
|
|
11
|
+
speaks fast (one cloned voice was measured saying 1234 at 9.2 syllables/s and dropping "nghìn", "trăm", "mươi").
|
|
12
|
+
|
|
13
|
+
So there are two rules, one before the voice and one after:
|
|
14
|
+
|
|
15
|
+
1. **The text sent to the voice never contains a digit.** Every number is written out in words by a deterministic
|
|
16
|
+
tool, in the reading the language really uses.
|
|
17
|
+
2. **Every clip with a number is checked by a recogniser**: the exact number must be heard, whole and in order. A
|
|
18
|
+
clip that fails is made again; it is never shipped on trust.
|
|
19
|
+
|
|
20
|
+
## The tool: `scripts/numwords.py`
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python numwords.py spell 1234 --lang vi # một nghìn hai trăm ba mươi bốn
|
|
24
|
+
python numwords.py spell 105 --all # the 10 voice languages
|
|
25
|
+
python numwords.py speak --lang vi "Bạn có 1234 sao và 105 xu."
|
|
26
|
+
# {"speak": "Bạn có một nghìn hai trăm ba mươi bốn sao và một trăm linh năm xu.", "numbers": [1234, 105], "issues": []}
|
|
27
|
+
python numwords.py heard --lang vi --numbers 1234 "bạn có một hai trăm ba mươi bốn sao" # exit 1: 1234 not heard
|
|
28
|
+
python numwords.py selftest
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`voice.py plan` calls `speak` for every line, so the `speak` text and the `numbers` list arrive with each line to
|
|
32
|
+
synthesise. From Python: `numwords.speak(text, lang, style)`, `numwords.spell(n, lang)`, `numwords.heard(numbers,
|
|
33
|
+
transcript, lang)`.
|
|
34
|
+
|
|
35
|
+
Range: whole numbers 0 … 999,999,999,999. Also decimals written with the language's own mark (vi `3,5` → "ba phẩy
|
|
36
|
+
năm", en `3.5` → "three point five": the digits after the mark one by one), a leading minus, and digit strings with a
|
|
37
|
+
leading zero (`007` → "không không bảy").
|
|
38
|
+
|
|
39
|
+
## Readings (what the tool writes)
|
|
40
|
+
|
|
41
|
+
| | 105 | 1234 | 1005 | 21 |
|
|
42
|
+
|---|---|---|---|---|
|
|
43
|
+
| vi | một trăm linh năm | một nghìn hai trăm ba mươi bốn | một nghìn không trăm linh năm | hai mươi mốt |
|
|
44
|
+
| en | one hundred five | one thousand two hundred thirty-four | one thousand five | twenty-one |
|
|
45
|
+
| ja | ひゃくご | せんにひゃくさんじゅうよん | せんご | にじゅういち |
|
|
46
|
+
| ko | 백오 | 천이백삼십사 | 천오 | 이십일 |
|
|
47
|
+
| zh-Hans | 一百零五 | 一千二百三十四 | 一千零五 | 二十一 |
|
|
48
|
+
| es | ciento cinco | mil doscientos treinta y cuatro | mil cinco | veintiuno |
|
|
49
|
+
| pt-BR | cento e cinco | mil duzentos e trinta e quatro | mil e cinco | vinte e um |
|
|
50
|
+
| de | einhundertfünf | eintausendzweihundertvierunddreißig | eintausendfünf | einundzwanzig |
|
|
51
|
+
| fr | cent cinq | mille deux cent trente-quatre | mille cinq | vingt et un |
|
|
52
|
+
| id | seratus lima | seribu dua ratus tiga puluh empat | seribu lima | dua puluh satu |
|
|
53
|
+
|
|
54
|
+
## What each language gets wrong without the rules
|
|
55
|
+
|
|
56
|
+
| Language | The traps the tool handles |
|
|
57
|
+
|---|---|
|
|
58
|
+
| **vi** | the zero tens: 105 "một trăm **linh** năm" (or "**lẻ**"), never "một trăm năm" (= 150); the zero hundreds after a thousand: 1005 "một nghìn **không trăm** linh năm"; 15 "mười **lăm**", 25 "hai mươi **lăm**"; 21 "hai mươi **mốt**"; 10 "mười" but 20 "hai **mươi**" |
|
|
59
|
+
| **en** | no "and" by default (US: "one hundred five"); hyphen in 21–99 |
|
|
60
|
+
| **ja** | sound changes: 300 さん**び**ゃく, 600 ろ**っぴ**ゃく, 800 は**っぴ**ゃく, 3000 さん**ぜ**ん, 8000 は**っ**せん; 4 よん, 7 なな, 9 きゅう; 10,000 **いち**まん; 10,000,000 いっせんまん. Written in kana so nothing is left to read |
|
|
61
|
+
| **ko** | Sino-Korean for plain numbers; 10,000 is 만 (not 일만), 100,000,000 is 일억 |
|
|
62
|
+
| **zh-Hans** | 零 for a skipped place: 105 一百**零**五, 1005 一千**零**五; 110 一百**一**十; 10 is 十 but 一十 after a hundred; 2 is 两 before 千 / 万 / 亿 and before a measure word (2个 → 两个) |
|
|
63
|
+
| **es** | 100 "cien" but 101 "ciento uno"; 21 "veintiuno" but 21,000 "veinti**ún** mil"; 1,000 "mil" (not "un mil"); 10⁹ "mil millones" |
|
|
64
|
+
| **pt-BR** | "e" between hundreds, tens and units, and before the last group when it is under 100 or a round hundred: 1,200 "mil **e** duzentos", 1,234 "mil duzentos e trinta e quatro"; 100 "cem", 105 "cento e cinco"; 10⁹ "um bilhão" |
|
|
65
|
+
| **de** | units before tens: 21 "**ein**und**zwanzig**"; "eins" only at the very end (101 "einhunderteins", 1,001 "eintausendeins"); 16 "sechzehn", 17 "siebzehn", 30 "dreißig"; "eine Million" |
|
|
66
|
+
| **fr** | 70–99: "soixante-dix", "quatre-vingts", "quatre-vingt-onze"; "et" only in 21, 31 … 61 and 71; "quatre-vingts" and "deux cents" lose the s before another number or "mille" |
|
|
67
|
+
| **id** | the se- forms: 10 "sepuluh", 11 "sebelas", 100 "seratus", 1,000 "seribu" (never "satu ribu"); 12–19 "… belas" |
|
|
68
|
+
|
|
69
|
+
## What the tool will not guess: issues
|
|
70
|
+
|
|
71
|
+
`speak` returns `issues` when a number's reading depends on something only a person or the author knows. A line with
|
|
72
|
+
an issue is `blocked` in `voice.py plan` until it is settled, in this order of preference:
|
|
73
|
+
|
|
74
|
+
1. **Change the shown text** so nothing is left to guess: `1500` instead of `1.500` (the rule for whole numbers below
|
|
75
|
+
10,000 anyway, [format.md](format.md)), words instead of a symbol where the screen allows it.
|
|
76
|
+
2. Otherwise **write the spoken text** with `voice.py say` (next section).
|
|
77
|
+
|
|
78
|
+
| Issue | Example | Why it is not guessed |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `ambiguous` | `1.234`, `1,234`, `12.000`, `1 234` | one thousand two hundred thirty-four, or one point two three four, or two numbers? Vietnamese and German group with a dot, English with a comma, French with a space. (Two or more groups, `1.234.567`, and groups split by a no-break space are read as one number.) |
|
|
81
|
+
| `symbol` | `50%`, `12:30`, `3/4`, `2+3`, `5°`, `$10` | percent, time, fraction, date, score and sum are read differently in every language |
|
|
82
|
+
| `glued` | `A4`, `3D`, `5kg`, `1st`, `x2` | letters and digits together are a name, a unit or an ordinal |
|
|
83
|
+
| `counter` | ja `3つ`, `1本`, `2人`; ko `3개`, `5명` | Japanese counters change the reading (みっつ, いっぽん, ふたり); Korean counts things with native numbers (세 개, 다섯 명) but minutes and money with Sino-Korean ones |
|
|
84
|
+
| `large` | 10¹² and above | write it |
|
|
85
|
+
|
|
86
|
+
Things the tool cannot see at all, to settle when writing a line: years ("2026" as a year is "twenty twenty-six" in
|
|
87
|
+
English, "zweitausendsechsundzwanzig" in German), ordinals ("thứ 2", "le 1er", German "3." before a noun), phone
|
|
88
|
+
numbers and codes (write them with a leading zero or as words so they are read digit by digit), Spanish and
|
|
89
|
+
Portuguese gender agreement (doscient**as** monedas, du**as** estrelas), Roman numerals, and a product's own symbols.
|
|
90
|
+
A maths game's operators ("+", "×", "=") are the product's vocabulary: the product's voice tool maps them to words
|
|
91
|
+
before `speak` sees the text.
|
|
92
|
+
|
|
93
|
+
## Writing the spoken text by hand: `voice.py say`
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python voice.py say --lang ja --id game:say.reward "ほしを せんごひゃっこと コインを ひゃくごまい もらったよ!"
|
|
97
|
+
python voice.py say --lang vi --id shop:say.sale "Giảm năm mươi phần trăm hôm nay"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
It writes the override into `i18n/voice/speak/<lang>.json`:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{ "game:say.reward": { "text": "ほしを 1500こと コインを 105まい もらったよ!", "speak": "ほしを せんごひゃっこと コインを ひゃくごまい もらったよ!" } }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
and from then on the tool holds the override to three rules, so a hand-written reading cannot drift:
|
|
107
|
+
|
|
108
|
+
- **It says the numbers the shown text shows.** The numbers are read from the shown text (`1500`, `105`) and each
|
|
109
|
+
must be found in the spoken text in one of its accepted readings, counter readings included (ひゃっこ, みっつ,
|
|
110
|
+
세 개). "Giảm năm phần trăm" for a text that shows `50%` is refused. The same list goes with the line to the check
|
|
111
|
+
after synthesis.
|
|
112
|
+
- **It contains no digit.**
|
|
113
|
+
- **It belongs to one shown text.** `text` records the sentence it was written for. When that sentence changes (the
|
|
114
|
+
reward becomes 2000), the line is `blocked` again until the spoken text is rewritten: an old reading never
|
|
115
|
+
survives a changed number.
|
|
116
|
+
|
|
117
|
+
For a draft, `numwords.py speak --lenient --lang vi "…1.500…"` prints the text with grouped numbers read by the
|
|
118
|
+
language's own convention. It never invents a reading for symbols or counters. If a correct reading is one the tool
|
|
119
|
+
does not know (a year said as "twenty twenty-six", a product name with a number), pass `--numbers` with the numbers
|
|
120
|
+
the spoken text really says (`--numbers ""` for none) and note why in the commit.
|
|
121
|
+
|
|
122
|
+
## Style choices (per project, in `i18n.config.json` → `voice.numberStyle`)
|
|
123
|
+
|
|
124
|
+
| Language | Option | Default | Other |
|
|
125
|
+
|---|---|---|---|
|
|
126
|
+
| vi | `linh` | `linh` (một trăm linh năm) | `lẻ` (một trăm lẻ năm) |
|
|
127
|
+
| vi | `four` | `bốn` (ba mươi bốn) | `tư` (ba mươi tư) |
|
|
128
|
+
| vi | `thousand` | `nghìn` | `ngàn` |
|
|
129
|
+
| en | `and_` | `false` (one hundred five) | `true` (one hundred and five) |
|
|
130
|
+
| ja | `zero` | `ゼロ` | `れい` |
|
|
131
|
+
| zh-Hans | `liang` | `true` (两千) | `false` (二千) |
|
|
132
|
+
|
|
133
|
+
Both readings in each pair are correct, and the check after synthesis accepts both. What matters is one style per
|
|
134
|
+
product per language: a child must not hear "linh" in one question and "lẻ" in the next.
|
|
135
|
+
|
|
136
|
+
## After synthesis: was the number said?
|
|
137
|
+
|
|
138
|
+
`numwords.heard(numbers, transcript, lang)` takes the `numbers` list that came with the line and what a recogniser
|
|
139
|
+
wrote, and answers whether each number stands in the transcript whole and in order. It accepts the usual spoken
|
|
140
|
+
variants (linh / lẻ, bốn / tư, nghìn / ngàn, with or without "and", kana or kanji, 两 or 二, the readings before a
|
|
141
|
+
counter or a feminine noun: ひゃっこ, みっつ, 세 개, una, duas, une) and digits ("1.234", "1,234"). In the languages
|
|
142
|
+
written with spaces it rejects a match that is part of a longer number: 234 inside "một nghìn hai trăm ba mươi
|
|
143
|
+
bốn", "one hundred" inside "one hundred five" or "one hundred and five". A number after an ordinary "and / y / e /
|
|
144
|
+
et" ("stars and one hundred five coins") is its own number.
|
|
145
|
+
|
|
146
|
+
This is the floor for every product. It catches a swallowed "nghìn", swapped or missing numbers
|
|
147
|
+
and wrong order. It does not judge pronunciation, accent or pace, and in Japanese, Korean, Chinese and German (no
|
|
148
|
+
spaces between number words) it only checks that the reading is present, so small numbers are weakly checked there.
|
|
149
|
+
A product with many numbers adds its own gates. Gates that have proved their worth: two recognisers for Vietnamese,
|
|
150
|
+
exact kana comparison for Japanese, a pace limit for numbers (6.5 syllables/s for vi and en, 10 morae/s for ja),
|
|
151
|
+
pause and voice-quality checks.
|
|
152
|
+
|
|
153
|
+
A number that keeps failing after three takes at a slower speed is a line to rewrite (split the sentence, move the
|
|
154
|
+
number to the end), not a clip to accept.
|
|
155
|
+
|
|
156
|
+
## Building numbers from pieces
|
|
157
|
+
|
|
158
|
+
A game that speaks arbitrary numbers at runtime (a maths game's questions) cannot record every number. Compose them from
|
|
159
|
+
recorded pieces **with the same reading rules** as this tool (the game's number composer and `numwords` must agree: a
|
|
160
|
+
test spells 0–9999 with both and compares), cut the pieces from carrier sentences so they sound connected, and run the
|
|
161
|
+
`heard` check on assembled samples, not only on the pieces.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Unity games
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
1. The runtime contract
|
|
5
|
+
2. Where the files go
|
|
6
|
+
3. Loading and updating packs
|
|
7
|
+
4. Text, fonts and layout
|
|
8
|
+
5. Language setting, picker, the wire
|
|
9
|
+
6. Tests a game must have
|
|
10
|
+
7. Adopting the standard in an existing game
|
|
11
|
+
|
|
12
|
+
There is no shared Unity package yet. The first game to implement this contract should write it as a small UPM
|
|
13
|
+
package (pure C# core with no engine references + a thin Unity layer), so the second game installs it instead of
|
|
14
|
+
copying. Until then each game's own `Loc` class must behave as described here.
|
|
15
|
+
|
|
16
|
+
## 1. The runtime contract
|
|
17
|
+
|
|
18
|
+
A game's localisation code does exactly these things, and the same way in every game:
|
|
19
|
+
|
|
20
|
+
| Behaviour | Rule |
|
|
21
|
+
|---|---|
|
|
22
|
+
| Key | `ns:key.path` (a default namespace may be implied). Lookup is a dictionary hit on the pack's flat keys |
|
|
23
|
+
| Placeholders | `{{name}}` replaced from named values; an unknown name is left as written and logged in development builds |
|
|
24
|
+
| Plurals | with a `count` value: look up `key_<category>` where the category comes from the language's CLDR rule, then `key_other`, then the fallback chain. Port `plural_category()` from `scripts/i18n.py` |
|
|
25
|
+
| Fallback | active language (downloaded pack over bundled pack) → the manifest's `fallback` list → source language → the key itself |
|
|
26
|
+
| Change | `SetLanguage(code)` raises one event; every visible label re-reads its text in that frame. No restart, no scene reload unless content itself is per-language |
|
|
27
|
+
| Formatting | numbers, dates and durations are formatted in code for the active language before they go into a placeholder |
|
|
28
|
+
| Safety | a pack is data. Its texts are never evaluated, used as format strings for `string.Format`, or shown as rich text unless the label is meant to hold rich text |
|
|
29
|
+
|
|
30
|
+
Minimal API shape (names may follow the game's existing class):
|
|
31
|
+
|
|
32
|
+
```csharp
|
|
33
|
+
Loc.T("shop:title");
|
|
34
|
+
Loc.T("shop:buy", ("price", price));
|
|
35
|
+
Loc.T("shop:items", ("count", n)); // picks shop:items_one / _few / _many / _other
|
|
36
|
+
Loc.Language; // "ja", "pt-BR", "zh-Hans"
|
|
37
|
+
Loc.SetLanguage("ko"); // event: Loc.Changed
|
|
38
|
+
Loc.Available; // ready languages from the manifest: code, name, native, state
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Do not keep a second copy of the source text in code (`Loc.T("key", "Tiếng Việt")`) in new code: the source file is
|
|
42
|
+
the single place a text lives, and a test (section 6) catches a key that is missing from it.
|
|
43
|
+
|
|
44
|
+
## 2. Where the files go
|
|
45
|
+
|
|
46
|
+
- `i18n/` at the repository root is the source of truth ([layout-and-versioning.md](layout-and-versioning.md)).
|
|
47
|
+
- `bundle.copyTo` → `Assets/<Game>/Resources/i18n/`: `pack` writes `<lang>.json` and `manifest.json` there with
|
|
48
|
+
stable names. `Resources` is deliberate: packs must be readable synchronously before the first scene on every
|
|
49
|
+
platform (on Android, `StreamingAssets` sits inside the APK and needs a web request). Each language is its own
|
|
50
|
+
`TextAsset`, so only the active one and its fallbacks are loaded into memory.
|
|
51
|
+
- Downloaded packs: `Application.persistentDataPath/i18n/c<compat>/` (`manifest.json`, `<lang>.<hash12>.json`).
|
|
52
|
+
- Voice clips: `Application.persistentDataPath/voice/clips/<lang>/…` with the set indexes beside them. A clip is
|
|
53
|
+
played only when the hash of the text now shown for that key is in the index entry's `text` list
|
|
54
|
+
([voice.md](voice.md) §9: the index lists the hashes of the texts a clip may be played with); add a test with the
|
|
55
|
+
vector given there.
|
|
56
|
+
- Never edit the copies under `Assets/`: change `i18n/locales`, run `pack`.
|
|
57
|
+
|
|
58
|
+
## 3. Loading and updating packs
|
|
59
|
+
|
|
60
|
+
Start-up (before the first scene, `RuntimeInitializeOnLoadMethod(BeforeSceneLoad)`):
|
|
61
|
+
1. Read the saved language, or choose the default ([languages.md](languages.md)).
|
|
62
|
+
2. Load the bundled manifest; load the downloaded manifest if there is one.
|
|
63
|
+
3. For the language and each fallback, load the copy with the higher `version`; keep the bundled one underneath.
|
|
64
|
+
|
|
65
|
+
Background, after the first screen is up, at most once per launch:
|
|
66
|
+
4. `GET <cdn>/i18n/c<compat>/manifest.json` (5 s timeout). On any error: stop silently.
|
|
67
|
+
5. For the active language and every language already downloaded: if the CDN `version` is higher, download `file`,
|
|
68
|
+
check SHA-256 against `hash`, write to `*.tmp`, rename over the final name, save the new manifest. Apply on the
|
|
69
|
+
next `SetLanguage` or at the next launch; applying immediately is allowed if the screen can refresh.
|
|
70
|
+
6. Delete downloaded packs that are older than the bundled ones (after an app update) and files no manifest names.
|
|
71
|
+
|
|
72
|
+
A language that is in the CDN manifest but not in the app (added after the release) is downloaded when the user picks
|
|
73
|
+
it: show progress, keep the old language until the hash check passed.
|
|
74
|
+
|
|
75
|
+
Addressables content (chapters, models) stays in Addressables. Text packs and voice clips are plain files on purpose:
|
|
76
|
+
a new language or a corrected sentence must not need a Unity build.
|
|
77
|
+
|
|
78
|
+
## 4. Text, fonts and layout
|
|
79
|
+
|
|
80
|
+
- **Capabilities**: legacy uGUI `Text` and plain TextMeshPro do not shape Arabic, Persian, Urdu, Hindi, Bengali,
|
|
81
|
+
Tamil or Thai and do not lay out right-to-left. Leave `capabilities` empty until a shaping solution is in and a
|
|
82
|
+
screenshot of real sentences proves it. Those 8 languages are then simply not offered: better than broken text.
|
|
83
|
+
- **Fonts**: check every script the product offers on a real device of each platform. The game's own font covers
|
|
84
|
+
some scripts (M PLUS Rounded 1c: Latin, Cyrillic, Greek, Japanese); for others a dynamic font falls back to the
|
|
85
|
+
operating system's fonts, which usually exist for Korean, Chinese and Thai but look different and can be missing on
|
|
86
|
+
desktop. Where the fallback is missing or unacceptable, ship a font for that script (Noto Sans KR / SC / TC / Thai)
|
|
87
|
+
as a downloadable asset tied to the language, not inside the base app: a CJK font is 5–10 MB.
|
|
88
|
+
- **Layout**: labels grow. Enable best-fit or wrapping with a minimum size on buttons and tabs, never a fixed width
|
|
89
|
+
cut to the Vietnamese word. German and Russian are the overflow test; Thai, Korean and Chinese are the font test.
|
|
90
|
+
- **Line breaking**: Japanese, Chinese and Thai have no spaces. If the text component breaks only at spaces, insert
|
|
91
|
+
zero-width spaces at allowed break points when loading the pack, or keep such texts short.
|
|
92
|
+
- Baked labels in scenes and prefabs hold a key (a `LocalizedText` component), not a sentence. Editor builders attach
|
|
93
|
+
it when they create a label.
|
|
94
|
+
- Text inside textures, videos and 3D signs is content: either keep it language-neutral or treat it as a
|
|
95
|
+
per-language asset.
|
|
96
|
+
|
|
97
|
+
## 5. Language setting, picker, the wire
|
|
98
|
+
|
|
99
|
+
- Store the language as its **code string** (`"pt-BR"`), in settings and in every network message. An enum or a byte
|
|
100
|
+
cannot name a language added by a download.
|
|
101
|
+
- Default on first launch: the device's ordered language list, matched against the ready languages
|
|
102
|
+
([languages.md](languages.md)). Read the list natively (iOS `NSLocale.preferredLanguages`, Android
|
|
103
|
+
`LocaleList.getDefault()`); `Application.systemLanguage` is the fallback.
|
|
104
|
+
- An install that already has a saved language keeps it through updates.
|
|
105
|
+
- The picker: searchable list, rows `English name (native name)`, state per row, globe icon
|
|
106
|
+
([languages.md](languages.md)).
|
|
107
|
+
- **Server-written texts** (refusals, notices): the server sends `key` + named values and the client renders them in
|
|
108
|
+
its own language. The server then needs no translation tables and speaks all 40 languages at once. For old clients,
|
|
109
|
+
keep sending a rendered source-language string beside the key until they are gone. A protocol change follows the
|
|
110
|
+
project's own contract rules.
|
|
111
|
+
- iOS: put the ready languages in `CFBundleLocalizations` (post-process the Xcode project). Android: `locales_config`.
|
|
112
|
+
|
|
113
|
+
## 6. Tests a game must have
|
|
114
|
+
|
|
115
|
+
| Test | Catches |
|
|
116
|
+
|---|---|
|
|
117
|
+
| EditMode: `python i18n.py check` exits 0 (run it from the test or from the build script) | broken placeholders, missing plural forms, forbidden words |
|
|
118
|
+
| EditMode: every key the code uses exists in the source (extract `Loc.T("…")` literals and keys held by `LocalizedText`) | a typo in a key, a deleted text still in use |
|
|
119
|
+
| EditMode: the C# plural rule returns the category in `assets/plural-vectors.json` for every language and number | a wrong plural port |
|
|
120
|
+
| EditMode: bundled `manifest.json` hashes equal the SHA-256 of the bundled files | a hand-edited copy under `Assets/` |
|
|
121
|
+
| PlayMode: for each ready language, open the main screens and capture them | overflow, missing glyphs (tofu boxes), untranslated labels |
|
|
122
|
+
| PlayMode: first launch with device language X selects X (inject the device list) | default-language regressions |
|
|
123
|
+
| Device: download of a newer pack with the network cut mid-way leaves the old pack working | update safety |
|
|
124
|
+
|
|
125
|
+
## 7. Adopting the standard in an existing game
|
|
126
|
+
|
|
127
|
+
Do it as its own approved piece of work, never in passing while changing something else. Re-read the game's
|
|
128
|
+
localisation code first: the table lists what such code usually looks like and where it goes.
|
|
129
|
+
|
|
130
|
+
| Usually found | Standard |
|
|
131
|
+
|---|---|
|
|
132
|
+
| string tables under `Assets/…/Resources/`, one per language, sometimes wrapped (`{"language": …, "strings": {…}}`) | `i18n/locales/<lang>/<ns>.json` holding the strings only; `pack` writes the bundle copies back under `Resources/i18n/` |
|
|
133
|
+
| the source text also written in code (`Loc.T("key", "source text")`) and pulled out by an extractor | keep the extractor for now and point its output at `i18n/locales/<source>/`; new code uses keys only |
|
|
134
|
+
| positional `{0}` or single-brace `{name}` placeholders | `{{name}}`: convert the files and the formatter in one commit, with its tests ([format.md](format.md), legacy formats) |
|
|
135
|
+
| languages hard-coded in an array or an `enum`, sometimes sent over the network as a byte | the manifest decides the list; the language is a code string in settings and on the wire (a contract change) |
|
|
136
|
+
| a server-side table with one column per language | a `server` namespace in the locales; the server sends key + values |
|
|
137
|
+
| "write the sentence so one form fits every number" | plural keys wherever a count is shown, before adding a language that needs them |
|
|
138
|
+
| product rules about words (a word that must never be shown, names never translated) | `glossary.json`: `forbidden`, `keep` |
|
|
139
|
+
| translations that already exist | check them, then `i18n.py stamp --all` |
|
|
140
|
+
| voice clips inside the app | they may stay; a new voice language is CDN-only, so the player needs a path that plays downloaded clips |
|
|
141
|
+
| numbers composed from recorded pieces by per-language code | the reading rules as data, tested against `numwords.py` with the product's `numberStyle` |
|
|
142
|
+
| a content CDN that already serves other downloads | add the `i18n/` and `voice/` prefixes and their cache behaviours ([layout-and-versioning.md](layout-and-versioning.md) §7) |
|