mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-28 03:57:57 -06:00
Port of PR #198 onto the language table: - Traditional Chinese (Taiwan) catalogs as a table entry: code zh-hant, name 繁體中文(台灣), script Hant; zh-TW / zh-HK / zh-Hant tags reach it; command app.language.traditionalChinese - display-only helpers: builtin_label (stock preset/profile names), history_label (generated history steps, user preset names verbatim), source_label (library headings, album names verbatim), date_group_label / display_time - menu, dialog and panel strings (profiles, presets, curves, crop, versions, history, grid, date sidebar, About links) go through the catalogs - a language command and ui.set apply the language at once; a native-menu test checks that every language switch rebuilds the menu titles Adapted while porting (Claude): - date headings and capture times are localised for every language from its *-formats.json date patterns, not only for zh-TW; ja and zh-hans gain the date patterns, weekday names and "Unknown Date", and zh-hans the new menu messages (ja's come from the PR) - plain catalogs may cover different messages (English fallback); the test reports the gaps instead of failing. The test requiring every engine command label to be translated is dropped - preset groups stay grouped by name: a user preset in a stock-named group is not split into a separate group (the group header is translated when it holds stock presets); the PR's split was a side effect of labelling - no Traditional Chinese face in craft-fonts yet: Hant prefers the Simplified Chinese face (which carries the Traditional characters) over the Japanese ones - zh-hant translations for the messages main added since the PR branched Co-authored-by: Codex <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
2.6 KiB
Markdown
37 lines
2.6 KiB
Markdown
# LightCraft 简体中文界面
|
||
|
||
LightCraft 的界面支持简体中文、日语和英语。语言设置保存在 `ui.json` 的 `language` 字段中。
|
||
|
||
- 通过「编辑 → 语言」或「设置 → 一般 → 语言」切换,选择会保留到下次启动。
|
||
- 已翻译的范围:菜单、照片编辑、蒙版、裁剪、设置、导入、导出,以及主要的进度提示。
|
||
- 正文字重与半粗体都使用 SIL OFL 的 **Noto Sans CJK SC**(简体中文)与 BIZ UDPGothic(日语)。
|
||
这些字体不在本仓库,而在 [storytold/craft-fonts](https://github.com/storytold/craft-fonts);
|
||
使用可选的构建输入 `CRAFT_FONTS_DIR=../craft-fonts` 时(所有正式发布版)会内嵌进来。
|
||
不指定该输入时程序照常构建运行,但中文与日文文字没有字形,会显示为方框。
|
||
- 翻译只发生在显示层:命令 ID、照片文件名、用户输入的元数据都不做改动。
|
||
- 尚未翻译的技术性错误、补充说明和发行说明仍以英文显示。
|
||
- 已知限制:**网页版(wasm32)目前只内嵌日文字体**,因此浏览器里的中文仍显示为方框
|
||
(单个字体文件 16 MB,加上 wasm 会超过托管方 Cloudflare 的 25 MiB 单文件上限)。
|
||
原生桌面版不受影响。
|
||
- 日期分组标题与拍摄时间按中文格式显示(如 `2026年9月20日 星期日`)。
|
||
|
||
## 翻译的维护
|
||
|
||
静态界面文字在 `crates/ui-egui/locales/zh-hans.json`,含运行时数值的文字在
|
||
`crates/ui-egui/locales/zh-hans-formats.json`。两者都以英文原文为键。
|
||
|
||
含数值的文字遵循以下约定:
|
||
|
||
- 每个译文都是普通的 Rust 格式字符串,构建时由 `format!` 对照调用点的参数检查(占位符写错会编译失败)。
|
||
- **按名字**:`{n}`、`{label}`、`{total}` 等与英文原文中的名字一致。
|
||
- **按位置**:`{0}`、`{1}` … 对应调用点无名参数的先后顺序(从 0 开始),用于调整语序,
|
||
例如 `Added {n} photo{} to “{}”` 译为 `已将 {n} 张照片添加到“{1}”{0:.0}`。
|
||
- 保留英文原文的格式说明(`{:.1}`、`{d:+}`、`{:.0}%`)。
|
||
- `format!` 不允许未使用的参数:英文用来表示单复数的那个参数(`"s"` / `""`)在中文里写成
|
||
`{:.0}`(精度为 0 的字符串不输出任何内容)。
|
||
|
||
`LIGHTCRAFT_LANGUAGE=zh-hans lightcraft-cli snapshot ...` 可以渲染中文界面用于检查。
|
||
|
||
翻译是否完整、两种目录的键与占位符是否一致、字形是否齐全,都由
|
||
`cargo test -p lightcraft-ui-egui i18n::tests` 验证(字形检查只在指定 `CRAFT_FONTS_DIR` 时实际执行)。
|