lightcraft/docs
goujicheng 22eb4d3515 LR-BEHAV-LOCALIZE: a language table, Simplified Chinese, and per-script font fallback
The localization layer was hardcoded to English and Japanese: an enum with two
variants, an `is_japanese()` gate compiled into the format macro, and one
catalog pair. Adding a language meant editing the menus, the settings row, the
checkmark logic, the format macro and the font stack — each in a different place.

A language is now one entry in `i18n::language_table!`: BCP-47 code, endonym,
ISO 15924 script and catalog. The Language menu, the settings row, the shortcut
sheet and the control channel are all built from that table, and `build.rs`
picks up `locales/<code>-formats.json` by name, so a further language is a table
entry plus two catalogs (docs/localization.md).

Simplified Chinese (`zh-hans`) ships as the second translation: `zh-hans.json`
(1019 entries, key-set and placeholder-identical to `ja.json`) and
`zh-hans-formats.json` (102 entries). Its glyphs come from craft-fonts' Noto
Sans CJK SC, whose `Hans` faces the UI now installs *before* the Japanese ones
for a Chinese reader, so shared Han characters keep the language's forms
(`fonts::cjk_fallback`); the export watermark accepts every CJK face.

`tr_format!` keeps its compile-time check. It formats the English source at the
call site — a runtime template cannot be handed to `format!` — and names those
values so a translation can place them by name (`{n}`) or position (`{_1}`).
Every translation is still checked by `format!`, so a translation with an
unknown placeholder fails the build. The Japanese catalog was rewritten from the
old `{:.0}` plural-discard trick to that by-name form; behaviour is unchanged.

Also: settings persist the BCP-47 code (never the Rust variant name),
`LIGHTCRAFT_LANGUAGE` accepts system-style tags (`zh_CN`, `ja_JP.UTF-8`),
`xtask parity` reads the second command table, and the glyph tests cover every
catalog character plus the interface symbols (`▸`/`▾` turned out to have no
glyph in any installed font and are gone from the Chinese text).

Chinese and Japanese both need `CRAFT_FONTS_DIR` as before; the web build still
embeds only the Japanese face (Noto Sans CJK SC alone would push the wasm past
Cloudflare's 25 MiB per-file cap), documented in docs/localization-zh-hans.md.

Co-Authored-By: DeepSeek V3.2 <noreply@deepseek.com>
2026-10-07 12:22:15 +08:00
..
brand Licensing: MIT OR Apache-2.0 files, NOTICE, ArtCraft brand terms 2026-10-04 10:05:02 -04:00
images docs: README (MCP, CLI, export, status, contributing), AGENTS.md (asset enforcement, crash recovery, testing/perf), screenshots re-captured with Inter 2026-09-30 23:52:34 -04:00
showcase M1.4: crash-safe catalog persistence (op log + snapshot) 2026-09-30 23:40:40 -04:00
camera-preview-colour.md Issue #148: Raw: read white balance, black level and crop of pre-2017 Sony ARWs 2026-10-06 15:27:33 -04:00
control-protocol.md Issue #104: keep file-system calls off the UI thread 2026-10-05 18:58:04 -04:00
gpu-pipeline.md Issue #136: Windows: use DX12 by default, honour WGPU_BACKEND, never let GPU init block startup 2026-10-06 10:16:05 -04:00
localization-ja.md LR-BEHAV-LOCALIZE: a language table, Simplified Chinese, and per-script font fallback 2026-10-07 12:22:15 +08:00
localization-zh-hans.md LR-BEHAV-LOCALIZE: a language table, Simplified Chinese, and per-script font fallback 2026-10-07 12:22:15 +08:00
localization.md LR-BEHAV-LOCALIZE: a language table, Simplified Chinese, and per-script font fallback 2026-10-07 12:22:15 +08:00
mcp.md Issue #99: Library: exclusive lock so two processes can't open one library 2026-10-05 17:48:34 -04:00
merge.md Merge main (Photo Merge); M1.14b: stack merge results with their sources 2026-10-01 11:00:51 -04:00
parity.md LR-BEHAV-LOCALIZE: a language table, Simplified Chinese, and per-script font fallback 2026-10-07 12:22:15 +08:00
web.md Fonts: use craft-fonts as an optional build input; move the Japanese fonts out 2026-10-06 11:35:02 -04:00
whats-new.md Issue #148: Raw: read white balance, black level and crop of pre-2017 Sony ARWs 2026-10-06 15:27:33 -04:00
xmp-interop.md Issue #92: XMP: merge into an existing sidecar instead of replacing it 2026-10-05 17:08:18 -04:00