sisyo 1.6.7 → 1.7.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/README.md +6 -1
- package/bin/known-hashes.json +109 -0
- package/bin/sisyo.js +285 -285
- package/package.json +30 -30
- package/templates/.claude/rules/agents-and-tests.md +24 -0
- 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 +13 -10
- 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/neon-game-ui-ux-skill/COMPONENTS.md +490 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -0
- package/templates/SISYO.md +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Languages: which ones, when they show, how one is chosen
|
|
2
|
+
|
|
3
|
+
The registry is `assets/languages.json` (code, English name, native name, script, direction, plural forms, voice,
|
|
4
|
+
rendering needs, aliases, fallback). `python scripts/i18n.py languages` prints it with the project's view.
|
|
5
|
+
|
|
6
|
+
## The two sets
|
|
7
|
+
|
|
8
|
+
| Set | Languages | Rule |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| **Text (default)** | 40: en, ja, es, pt-BR, ko, zh-Hans, de, fr, vi, id, zh-Hant, it, ru, tr, pl, nl, th, uk, cs, sv, da, nb, fi, el, hu, ro, sk, hr, bg, ca, ms, fil, hi, bn, ta, ar, he, fa, ur, pt-PT | every product translates its text into all of them, minus what its renderer cannot show (below). |
|
|
11
|
+
| **Voice** | 10: en, ja, es, pt-BR, ko, zh-Hans, de, fr, vi, id | the default voice set, the languages a voice backend is expected to cover. Voice is made only for the languages **and** lines a product names ([voice.md](voice.md)) |
|
|
12
|
+
|
|
13
|
+
Codes are BCP-47: language, then script or region where it matters (`zh-Hans`, `zh-Hant`, `pt-BR`, `pt-PT`). Use
|
|
14
|
+
exactly these codes in folders, config, manifests, settings and on the wire. Legacy codes are mapped, never stored:
|
|
15
|
+
`jp`→`ja`, `iw`→`he`, `in`→`id`, `tl`→`fil`, `no`→`nb`, `zh-CN`→`zh-Hans`, `zh-TW`→`zh-Hant`.
|
|
16
|
+
|
|
17
|
+
A language outside the registry (a new market) is added in the project's `extraLanguages` with the same fields, or to
|
|
18
|
+
the registry itself when every product should get it. Take the plural forms from
|
|
19
|
+
`new Intl.PluralRules(code).resolvedOptions().pluralCategories`.
|
|
20
|
+
|
|
21
|
+
## What the renderer can show: `capabilities`
|
|
22
|
+
|
|
23
|
+
Some scripts need more than glyphs. A language that needs a capability the project has not declared is `blocked`: it
|
|
24
|
+
is not translated, not packed, not offered. Declaring a capability is a claim that was **tested with a screenshot**.
|
|
25
|
+
|
|
26
|
+
| Capability | Needed by | What it means |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `rtl` | ar, he, fa, ur | right-to-left paragraphs, mirrored layout, bidirectional text with numbers and Latin words |
|
|
29
|
+
| `shaping` | ar, fa, ur, hi, bn, ta, th | letters join or reorder, marks stack (OpenType GSUB/GPOS). Without it the text is wrong, not just ugly |
|
|
30
|
+
|
|
31
|
+
| Platform | `capabilities` |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Web (browser), Electron, native iOS/Android text, React Native, Flutter | `["rtl", "shaping"]`; RTL still needs the layout checked (`dir="rtl"`, logical CSS properties) |
|
|
34
|
+
| Unity uGUI legacy `Text`, TextMeshPro without a plugin | `[]` → 32 languages (the 8 above stay blocked) |
|
|
35
|
+
| Unity with a shaping solution (UI Toolkit's Advanced Text Generator in Unity 6, or an RTL/HarfBuzz plugin) | declare what a screenshot test of real sentences proves |
|
|
36
|
+
|
|
37
|
+
Fonts are a separate matter from shaping: CJK, Cyrillic, Greek and Thai glyphs must exist in a font the product ships
|
|
38
|
+
or can fall back to. Per script, the Noto family is the safe default (Noto Sans JP / KR / SC / TC / Thai / Devanagari /
|
|
39
|
+
Bengali / Tamil / Arabic / Hebrew; Latin, Greek and Cyrillic are in Noto Sans). See the platform file for how each
|
|
40
|
+
runtime loads them.
|
|
41
|
+
|
|
42
|
+
## When a language appears in the app
|
|
43
|
+
|
|
44
|
+
A language is offered only when its manifest entry says `status: "ready"`: every text is translated and current. A `partial` language is packed (so a user who already chose it keeps it
|
|
45
|
+
and gets fallbacks for the gaps) but is not listed for new users.
|
|
46
|
+
|
|
47
|
+
This is why translating belongs to the feature: adding one untranslated text turns 39 languages `partial`, and
|
|
48
|
+
`pack` refuses to write that regression.
|
|
49
|
+
|
|
50
|
+
## The language picker
|
|
51
|
+
|
|
52
|
+
- A searchable list (type-ahead), one row per ready language: **`<English name> (<native name>)`**, for example
|
|
53
|
+
`Japanese (日本語)`, `Vietnamese (Tiếng Việt)`. Both names come from the manifest.
|
|
54
|
+
- The search matches the English name, the native name and the code, ignoring case and accents: "tieng viet" finds
|
|
55
|
+
Tiếng Việt; "japan", "ja" and "日本" find Japanese.
|
|
56
|
+
- Order: the device's languages first, then the current one, then the rest by English name.
|
|
57
|
+
- Each row shows its state: in the app / downloaded / needs download with the size. Changing language applies
|
|
58
|
+
immediately, without a restart, and is saved.
|
|
59
|
+
- The control that opens the picker carries a globe icon and the word "Language" in the current language **and** in
|
|
60
|
+
English, so someone who landed in a language they cannot read finds the way back.
|
|
61
|
+
- Voice, where a product has it, is a second setting ("Voice: …") that lists only the voice languages that product
|
|
62
|
+
ships. It defaults to the text language when that has voice, else to the product's `voice.fallback`.
|
|
63
|
+
|
|
64
|
+
## The default language on first launch
|
|
65
|
+
|
|
66
|
+
1. Read the device's **ordered list** of preferred languages (iOS `Locale.preferredLanguages`, Android `LocaleList`,
|
|
67
|
+
browser `navigator.languages`). Unity's `Application.systemLanguage` gives one coarse value and cannot tell
|
|
68
|
+
`pt-BR` from `pt-PT` or `zh-Hans` from `zh-Hant`: use it only as the last resort.
|
|
69
|
+
2. For each device language in order, take the first ready language that matches by: exact code → `aliases` → same
|
|
70
|
+
language and script (`zh-Hant-HK` → `zh-Hant`) → same base language (`es-MX` → `es`, `fr-CA` → `fr`).
|
|
71
|
+
3. Nothing matched → `en`; no English → the source language.
|
|
72
|
+
4. Save the choice. From then on only the user changes it. An app update never changes a saved language.
|
|
73
|
+
|
|
74
|
+
Stores read the supported languages from the build: list the ready languages in iOS `CFBundleLocalizations` and
|
|
75
|
+
Android `locales_config` / `resConfigs`, so the store page and the per-app language setting show them.
|
|
76
|
+
|
|
77
|
+
## Fallback for a missing text
|
|
78
|
+
|
|
79
|
+
`active language → its fallback list → source language → the key`. The manifest's `fallback` list is the registry's
|
|
80
|
+
(`pt-PT → pt-BR`, `ca → es`) followed by `en` and the source language. Never fall back across unrelated languages
|
|
81
|
+
(Ukrainian does not fall back to Russian, Traditional Chinese does not fall back to Simplified).
|
|
82
|
+
|
|
83
|
+
## Plural forms per language
|
|
84
|
+
|
|
85
|
+
| Forms | Languages |
|
|
86
|
+
|---|---|
|
|
87
|
+
| other | ja, ko, zh-Hans, zh-Hant, vi, id, th, ms |
|
|
88
|
+
| one, other | en, de, nl, sv, da, nb, fi, el, hu, tr, bg, fil, hi, bn, ta, fa, ur |
|
|
89
|
+
| one, many, other | es, pt-BR, pt-PT, fr, it, ca (`many` is used for exact millions: give it the `other` wording) |
|
|
90
|
+
| one, few, other | ro, hr |
|
|
91
|
+
| one, few, many, other | ru, uk, pl, cs, sk |
|
|
92
|
+
| one, two, other | he |
|
|
93
|
+
| zero, one, two, few, many, other | ar |
|
|
94
|
+
|
|
95
|
+
On the web `Intl.PluralRules` picks the form. A runtime without it ports `plural_category()` from `scripts/i18n.py`
|
|
96
|
+
and tests itself against `assets/plural-vectors.json` (taken from ICU). "one" is not always the number 1: in French
|
|
97
|
+
and Brazilian Portuguese it is 0 and 1; in Russian it is 1, 21, 31…
|
|
@@ -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.
|