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,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) |
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Web and apps (i18next)
|
|
2
|
+
|
|
3
|
+
The standard format **is** i18next's, so a site that already uses `i18next`, `react-i18next` or `next-i18next` needs
|
|
4
|
+
configuration, not conversion.
|
|
5
|
+
|
|
6
|
+
## Project setup
|
|
7
|
+
|
|
8
|
+
- `i18n/` at the repository root as everywhere ([layout-and-versioning.md](layout-and-versioning.md)), or point
|
|
9
|
+
`localesDir` / `layout` at the folder the site already has:
|
|
10
|
+
- one file per language (`src/i18n/locales/en.json`): `"layout": "{lang}.json"` (namespace `translation`)
|
|
11
|
+
- per namespace (`public/locales/en/common.json`): `"layout": "{lang}/{ns}.json"`
|
|
12
|
+
- `capabilities: ["rtl", "shaping"]`: browsers render every script. All 40 languages are open, provided the layout is
|
|
13
|
+
checked right-to-left (below).
|
|
14
|
+
- Use the registry codes. A site that used `jp` renames the folder to `ja` and redirects old URLs.
|
|
15
|
+
|
|
16
|
+
## i18next configuration
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import i18n from 'i18next'
|
|
20
|
+
import { initReactI18next } from 'react-i18next'
|
|
21
|
+
import manifest from '../../i18n/manifest.json' // written by "i18n.py pack"
|
|
22
|
+
|
|
23
|
+
const ready = Object.entries(manifest.languages).filter(([, l]) => l.status === 'ready').map(([code]) => code)
|
|
24
|
+
const fallbackLng = Object.fromEntries(
|
|
25
|
+
Object.entries(manifest.languages).map(([code, l]) => [code, l.fallback]),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
i18n.use(initReactI18next).init({
|
|
29
|
+
lng: pickLanguage(ready), // below
|
|
30
|
+
supportedLngs: ready,
|
|
31
|
+
fallbackLng: { ...fallbackLng, default: [manifest.fallbackLanguage] },
|
|
32
|
+
load: 'currentOnly', // "pt-BR" is a language, not "pt" + region
|
|
33
|
+
ns: ['common'], defaultNS: 'common',
|
|
34
|
+
interpolation: { escapeValue: false }, // React escapes; keep the default {{ }} delimiters
|
|
35
|
+
returnNull: false,
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Keep i18next's defaults for everything the format relies on: `{{ }}` interpolation, `:` namespace separator, `.` key
|
|
40
|
+
separator, `_` plural separator, JSON v4 plurals.
|
|
41
|
+
|
|
42
|
+
Loading the texts, by size of the site:
|
|
43
|
+
- **Small site**: import the JSON of each language lazily (`import.meta.glob('../../i18n/locales/*/*.json')` in
|
|
44
|
+
Vite, dynamic `import()` elsewhere) and `i18n.addResourceBundle(lng, ns, data)`. Nothing is fetched at runtime.
|
|
45
|
+
- **Larger site / translations updated without a deploy**: `i18next-http-backend` with
|
|
46
|
+
`loadPath: '<cdn>/locales/{{lng}}/{{ns}}.json'` (the repository layout served as is), or fetch the pack file named
|
|
47
|
+
in the CDN manifest and add each namespace: `Object.entries(pack.strings).forEach(([ns, s]) =>
|
|
48
|
+
i18n.addResourceBundle(lng, ns, s, true, true))`. Flat dotted keys in the pack are read by i18next as they are.
|
|
49
|
+
- **Next.js**: `next-i18next` or the App Router's own i18n routing with the same files; locales list from the
|
|
50
|
+
manifest.
|
|
51
|
+
|
|
52
|
+
## Choosing the language
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
function pickLanguage(ready: string[], wantedList = navigator.languages ?? [navigator.language]): string {
|
|
56
|
+
const find = (code?: string) => code && ready.find(r => r.toLowerCase() === code.toLowerCase())
|
|
57
|
+
const saved = find(localStorage.getItem('lang') ?? undefined)
|
|
58
|
+
if (saved) return saved
|
|
59
|
+
const alias = (code: string) => Object.keys(manifest.languages).find(k =>
|
|
60
|
+
(manifest.languages[k].aliases ?? []).some(a => a.toLowerCase() === code.toLowerCase()))
|
|
61
|
+
for (const wanted of wantedList) {
|
|
62
|
+
let loc: Intl.Locale
|
|
63
|
+
try { loc = new Intl.Locale(wanted).maximize() } catch { continue } // zh-TW -> zh-Hant-TW
|
|
64
|
+
const hit = find(wanted) ?? find(alias(wanted)) ?? find(`${loc.language}-${loc.script}`)
|
|
65
|
+
?? find(loc.language) ?? find(alias(loc.language))
|
|
66
|
+
?? (loc.language === 'zh' ? undefined : ready.find(r => r.split('-')[0] === loc.language))
|
|
67
|
+
if (hit) return hit // es-MX -> es; pt-PT -> pt-BR when that is the only Portuguese
|
|
68
|
+
}
|
|
69
|
+
return find('en') ?? manifest.sourceLanguage
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This is the matching rule of [languages.md](languages.md) in code (tested on zh-TW, zh-MY, pt-PT, es-MX, no, iw, tl
|
|
74
|
+
and others); a game ports the same steps. Save the choice when the user changes it (`localStorage`, and the account
|
|
75
|
+
profile if there is one). A URL that names a language (`/ja/…`) wins over both.
|
|
76
|
+
|
|
77
|
+
## Page-level rules
|
|
78
|
+
|
|
79
|
+
- `<html lang="{code}" dir="{ltr|rtl}">` updated on every language change (`dir` comes from the manifest).
|
|
80
|
+
- Right-to-left: use logical CSS (`margin-inline-start`, `padding-inline-end`, `text-align: start`), flip directional
|
|
81
|
+
icons, test one Arabic page before declaring it done.
|
|
82
|
+
- Language switcher: the same picker rules as the games ([languages.md](languages.md)): searchable, rows
|
|
83
|
+
`English name (native name)`, a globe icon. `Intl.DisplayNames` may add the name in the current language as a third
|
|
84
|
+
search term.
|
|
85
|
+
- Numbers, dates, currency, lists and relative times: `Intl.NumberFormat`, `Intl.DateTimeFormat`, `Intl.ListFormat`,
|
|
86
|
+
`Intl.RelativeTimeFormat` with the active language, then pass the result into a `{{placeholder}}`.
|
|
87
|
+
- Fonts: a font stack with system CJK / Thai / Arabic fallbacks; do not ship one webfont for all scripts.
|
|
88
|
+
- SEO for public pages: one URL per language (`/en/…`, `/ja/…`), `<link rel="alternate" hreflang="…">` for every
|
|
89
|
+
ready language plus `x-default`, translated `<title>` and meta description (keep them in a `seo` namespace), and a
|
|
90
|
+
sitemap that lists the alternates. Static sites are generated per language from the same
|
|
91
|
+
locale files at build.
|
|
92
|
+
- Never build a sentence in JSX from fragments; use one key with placeholders, or `<Trans>` when markup must sit
|
|
93
|
+
inside the sentence (web-only namespace, see [format.md](format.md)).
|
|
94
|
+
|
|
95
|
+
## Checks for a web project
|
|
96
|
+
|
|
97
|
+
- `python i18n.py check` in CI; `i18n.py pack` before a release so `manifest.json` is current.
|
|
98
|
+
- A script (or `i18next-parser` in check mode) that fails when the code uses a key the source lacks.
|
|
99
|
+
- A visual pass per new language on the main pages at phone width: overflow, clipped buttons, mixed directions.
|
|
100
|
+
|
|
101
|
+
## Apps
|
|
102
|
+
|
|
103
|
+
| App type | How it uses the standard |
|
|
104
|
+
|---|---|
|
|
105
|
+
| React Native, Electron, Capacitor | i18next exactly as above; packs bundled, optional CDN update |
|
|
106
|
+
| Native iOS / Android, Flutter | the texts are still authored in `i18n/locales` (one source, same translation loop). No exporter exists yet: when the first such app appears, add an export step to `pack` that writes `.xcstrings` / `strings.xml` / `.arb` from the locale files, and keep those generated files out of hand editing |
|
|
107
|
+
| Store listing (name, subtitle, description, keywords, what's new) | a `store` namespace translated with the same loop; note the stores' length limits in `notes/store.json` |
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Translating with an agent
|
|
2
|
+
|
|
3
|
+
The agent is the translator. The tool hands over exactly what needs translating, with context, and refuses answers
|
|
4
|
+
that would break the app. Nothing is sent to an outside translation service.
|
|
5
|
+
|
|
6
|
+
## The loop for one language
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
python <skill>/scripts/i18n.py status # which languages need work
|
|
10
|
+
python <skill>/scripts/i18n.py todo --lang ja --limit 150 --out todo.ja.json
|
|
11
|
+
# translate: write done.ja.json
|
|
12
|
+
python <skill>/scripts/i18n.py apply done.ja.json # validates, writes locales/ja, stamps meta
|
|
13
|
+
python <skill>/scripts/i18n.py todo --lang ja … # repeat until "0 of 0"
|
|
14
|
+
python <skill>/scripts/i18n.py check --lang ja
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Keep `todo` / `done` files in a scratch folder, not in the repository.
|
|
18
|
+
|
|
19
|
+
`todo.<lang>.json` gives, per text: `id` (`ns:key`), `state` (`missing`, `stale`, `incomplete`), `source`,
|
|
20
|
+
`reference` (the same text in the reference language, when it is current), `note` (context, `max` length),
|
|
21
|
+
`current` (the old translation of a stale text: change only what the new source requires), `forms` (the plural forms
|
|
22
|
+
this language needs), `voice: true` (the line is spoken aloud in this language: see "Voice lines" below). At the top:
|
|
23
|
+
the language, its plural forms, and the glossary for it.
|
|
24
|
+
|
|
25
|
+
The answer file:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"lang": "ru",
|
|
30
|
+
"items": {
|
|
31
|
+
"shop:title": "Магазин",
|
|
32
|
+
"shop:buy": "Купить за {{price}} монет",
|
|
33
|
+
"shop:items": { "one": "{{count}} предмет", "few": "{{count}} предмета", "many": "{{count}} предметов", "other": "{{count}} предмета" }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`apply` rejects an item (and says why) when a placeholder is lost or invented, a plural form is missing, a forbidden
|
|
39
|
+
word appears, the note's `max` is exceeded, or the key is locked. Fix and apply again; accepted items are already saved.
|
|
40
|
+
|
|
41
|
+
## Order and scale
|
|
42
|
+
|
|
43
|
+
1. **English first** when the source is not English. It becomes the `reference` every other language sees, which
|
|
44
|
+
steadies meaning for languages where direct Vietnamese→X data is thin.
|
|
45
|
+
2. Then the other voice languages, then the rest.
|
|
46
|
+
3. Work in batches of 100–200 texts per language so every item gets attention and the answer file stays reviewable.
|
|
47
|
+
One namespace at a time (`--ns`) keeps context coherent.
|
|
48
|
+
4. Many languages at once: one sub-agent per language (or per small group), each running the loop above on its own
|
|
49
|
+
`--lang`. They write different files, so they do not collide; run `check` and `pack` once at the end, in the lead.
|
|
50
|
+
Translation batches are execution work: give them to the cheaper model tier, and keep the lead on the session
|
|
51
|
+
model for the review.
|
|
52
|
+
|
|
53
|
+
## Before translating: read
|
|
54
|
+
|
|
55
|
+
- `i18n/style.md`: audience, tone, form of address, per-language rules. If it is empty, fill in the top part from the
|
|
56
|
+
product's docs first: a translation without a brief guesses the register.
|
|
57
|
+
- `i18n/glossary.json`: `keep` (names never translated), `terms` (fixed translations), `forbidden`.
|
|
58
|
+
- The `note` of each text. When a short text has no note and its meaning is unclear ("Open", "Back", "Light"), look
|
|
59
|
+
at where the key is used in the code before translating, then add the note so the next language does not ask again.
|
|
60
|
+
|
|
61
|
+
## Rules for the translation itself
|
|
62
|
+
|
|
63
|
+
- Translate the **meaning for that screen**, not the words. A button is an action; a title is a noun phrase.
|
|
64
|
+
- **Placeholders** `{{name}}` are copied exactly, moved to where the grammar wants them. Never translate, rename or
|
|
65
|
+
drop one. (`{{count}}` may be omitted from a `_one` / `_zero` / `_two` form that spells the number out.)
|
|
66
|
+
- **Plural forms**: write every form the language has, each a full natural sentence. For es / pt / fr / it / ca the
|
|
67
|
+
`many` form (exact millions) is normally the `other` wording. Where a noun must agree with the number (Russian,
|
|
68
|
+
Polish, Arabic), make it agree; do not paste one form into all slots.
|
|
69
|
+
- **Length**: stay near the source length for buttons, tabs and labels. German, Russian, Finnish and Greek run 20–35%
|
|
70
|
+
longer: prefer the shorter natural wording. `max` in a note is a hard limit.
|
|
71
|
+
- **Register**: one form of address per language for the whole product, taken from `style.md` (for example informal
|
|
72
|
+
`du` / `tu` / `tú` in a children's game, polite form for payment and account screens if the brief says so).
|
|
73
|
+
- **Names and brands** in `keep` stay as written, in Latin letters, in every language.
|
|
74
|
+
- **Punctuation and typography of the target language**: full-width 、。!? in Japanese and Chinese; ¿…? ¡…! in
|
|
75
|
+
Spanish; in French a **no-break space (U+00A0)** before `: ; ! ?` (not a plain space, which lets the mark wrap
|
|
76
|
+
alone onto the next line, and not the narrow U+202F, which many game fonts lack; `check` warns about the plain
|
|
77
|
+
space); „…“ in German; no space before 。; the ellipsis character where the language uses it. Keep line breaks
|
|
78
|
+
(`\n`) and leading/trailing spaces as in the source.
|
|
79
|
+
- **Scripts**: zh-Hans and zh-Hant are different vocabularies as well as different characters (软件 / 軟體): translate
|
|
80
|
+
each, do not convert. pt-BR and pt-PT differ in wording and spelling.
|
|
81
|
+
- **Do not localise what the app formats**: digits, dates, prices and units arrive through placeholders already
|
|
82
|
+
formatted.
|
|
83
|
+
- **Digits written in the source sentence** keep their value. A whole number below 10,000 has no grouping mark in any
|
|
84
|
+
language (`1500`); from 10,000 up use the target language's grouping (`12,000` en, `12.000` de / vi, `12 000` fr
|
|
85
|
+
and ru with a no-break space). If the source itself has `1.500`, fix the source to `1500` first.
|
|
86
|
+
- **Culture**: replace an idiom by the natural expression of the target language; keep jokes only if they survive.
|
|
87
|
+
Nothing that reads as religious, political or rude in the target market.
|
|
88
|
+
- If a source text is itself wrong or unclear, do not translate around it: fix the source (or ask), then translate.
|
|
89
|
+
|
|
90
|
+
## Voice lines (`"voice": true` in `todo`)
|
|
91
|
+
|
|
92
|
+
The line will be spoken by the voice in this language, so translate it for the ear as well as the eye:
|
|
93
|
+
|
|
94
|
+
- Short, natural spoken sentences. No abbreviations, symbols (`%`, `&`, `+`, `/`), emoji or brackets that a voice
|
|
95
|
+
would have to guess: write the words.
|
|
96
|
+
- Numbers as plain digits without a grouping mark, so the tool can read them.
|
|
97
|
+
- Japanese and Korean put counters on numbers (`3つ`, `105まい`, `3개`), and the counter changes how the number is
|
|
98
|
+
read. Write the natural sentence; the tool will then mark the line `blocked`, and the same pass that translated it
|
|
99
|
+
writes its spoken text:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
python <skill>/scripts/voice.py plan --lang ja # which lines are blocked, and why
|
|
103
|
+
python <skill>/scripts/voice.py say --lang ja --id game:say.reward "ほしを せんごひゃっこと コインを ひゃくごまい もらったよ!"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`say` ties the spoken text to the shown text and checks that it says the same numbers ([numbers.md](numbers.md)).
|
|
107
|
+
- Changing the words of a voice line puts its clip one step behind the text: the clip must be remade, or kept on
|
|
108
|
+
purpose if the old words still fit ([voice.md](voice.md) §5). Do not reword a voiced line for taste alone.
|
|
109
|
+
|
|
110
|
+
## Review before it counts
|
|
111
|
+
|
|
112
|
+
1. `i18n.py check` with no errors; read every warning ("no … characters", "identical to the source", "Vietnamese
|
|
113
|
+
letters are left") and fix or consciously accept it.
|
|
114
|
+
2. Self-review each batch once as a reader of that language: does every line sound like something a native app would
|
|
115
|
+
say on that screen?
|
|
116
|
+
3. For the voice languages and the product's main markets, a second agent (fresh context) spot-checks a sample of
|
|
117
|
+
30–50 texts by translating them back and comparing meaning. Disagreements are fixed, not averaged.
|
|
118
|
+
4. Layout: after a language is first added, capture the main screens in that language (the product's screenshot
|
|
119
|
+
tests) and look for clipped or overflowing text. German and Russian find most overflow; Thai and CJK find most
|
|
120
|
+
font gaps.
|
|
121
|
+
|
|
122
|
+
## Corrections from people
|
|
123
|
+
|
|
124
|
+
A person's correction outranks the agent's wording. Apply it and lock it:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
python <skill>/scripts/i18n.py apply fix.ja.json --lock
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A locked text is never overwritten by a later `apply` unless `--force` is passed, and `--force` needs the owner's
|
|
131
|
+
word. When the source of a locked text changes, it shows up as `stale` with `"locked": true` in `todo`: propose the
|
|
132
|
+
new translation to the owner instead of applying it silently.
|
|
133
|
+
|
|
134
|
+
## Adopting translations that already exist
|
|
135
|
+
|
|
136
|
+
A project that already has translations shows them as `untracked`: present, but
|
|
137
|
+
never stamped against a source text. After checking that they match the current source, record that:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
python <skill>/scripts/i18n.py stamp --lang en # or --all
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
From then on a source change marks exactly the affected texts `stale`.
|