Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-BEHAV-LOCALIZE: one Language menu entry per language; parity reads the language table

Brandon Thomas87a58b418383
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index 92ac47ee0..5a7e0f304 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -366,7 +366,7 @@ mod tests {
/// The language menu covers every language, and a language's own command selects it.
#[test]
fn language_commands_cover_every_language() {
- let commands = [("app.language.english", Locale::En), ("app.language.zh-hans", Locale::ZhHans), ("app.language.japanese", Locale::Ja)];
+ let commands = [("app.language.english", Locale::En), ("app.language.simplifiedChinese", Locale::ZhHans), ("app.language.japanese", Locale::Ja)];
// One command per language, and every command reachable from the menu table.
assert_eq!(commands.len(), Locale::ALL.len());
for (id, language) in commands {
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 92910324d..9f63e1088 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -12,9 +12,9 @@ pub type UiCommand = (&'static str, &'static str, Option<&'static str>, &'static
/// The "Edit → Language" entries, one per language in [`crate::i18n::Locale::ALL`], so a language
/// added to the table shows up in the menu (and in the control channel's command list) by itself.
-const LANGUAGE_COMMANDS: &[UiCommand] = &[
+pub const LANGUAGE_COMMANDS: &[UiCommand] = &[
("app.language.english", crate::i18n::Locale::En.name(), None, "Edit>Language"),
- ("app.language.zh-hans", crate::i18n::Locale::ZhHans.name(), None, "Edit>Language"),
+ ("app.language.simplifiedChinese", crate::i18n::Locale::ZhHans.name(), None, "Edit>Language"),
("app.language.japanese", crate::i18n::Locale::Ja.name(), None, "Edit>Language"),
];
@@ -29,15 +29,13 @@ pub fn ui_commands() -> impl Iterator<Item = &'static UiCommand> {
pub fn language_from_command(id: &str) -> Option<crate::i18n::Locale> {
match id {
"app.language.english" => Some(crate::i18n::Locale::En),
- "app.language.zh-hans" => Some(crate::i18n::Locale::ZhHans),
+ "app.language.simplifiedChinese" => Some(crate::i18n::Locale::ZhHans),
"app.language.japanese" => Some(crate::i18n::Locale::Ja),
_ => None,
}
}
pub const UI_COMMANDS: &[UiCommand] = &[
- ("app.language.english", "English", None, "Edit>Language"),
- ("app.language.japanese", "日本語", None, "Edit>Language"),
("view.photoGrid", "Photo Grid", None, "View"),
("view.squareGrid", "Square Grid", None, "View"),
// G: Photo Grid ↔ Square Grid (from other views: the photo grid)
diff --git a/docs/localization.md b/docs/localization.md
index b846df7a8..3eb5efcaa 100644
--- a/docs/localization.md
+++ b/docs/localization.md
@@ -70,7 +70,7 @@ LIGHTCRAFT_LANGUAGE=zh-hans lightcraft-cli snapshot --demo --script tour.jsonl -
```
or, with the app running (`--control 7980`), run the language command
-(`engine.execute {"command": "app.language.zh-hans"}`) and take a screenshot.
+(`engine.execute {"command": "app.language.simplifiedChinese"}`) and take a screenshot.
## Language codes and settings
diff --git a/docs/parity.md b/docs/parity.md
index d81f60f90..fc9226782 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -503,7 +503,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins.
| LR-BEHAV-EMPTY-STATES | Empty states | P1 | ✅ | `crates/ui-egui/src/panels/mod.rs` (`empty_message`) | |
| LR-BEHAV-TOOLTIPS | Tooltips with shortcuts | P0 | ✅ | `crates/ui-egui/src/panels/bottombar.rs` | |
| LR-BEHAV-ACCESS | Accessibility | P2 | 🟡 | `crates/ui-egui/src/widgets.rs`, `crates/ui-egui/src/panels/grid.rs` | AccessKit (VoiceOver / Narrator / AT-SPI): sliders announce control and value, buttons / icon buttons / dropdowns / section headers / sources their labels and state, grid thumbnails file name, rating, flag and label; the canvas tools (crop, masks) are pointer-only; not audited with a screen reader |
-| LR-BEHAV-LOCALE | Language options | P2 | ✅ | `cmd:app.language.english`, `cmd:app.language.zh-hans`, `cmd:app.language.japanese` | Edit > Language lists every language in the table and the active one is checked; shared with Settings > General (docs/localization.md) |
+| LR-BEHAV-LOCALE | Language options | P2 | ✅ | `cmd:app.language.english`, `cmd:app.language.simplifiedChinese`, `cmd:app.language.japanese` | Edit > Language lists every language in the table and the active one is checked; shared with Settings > General (docs/localization.md) |
| LR-BEHAV-LOCALIZE | Localisation | P2 | 🟡 | `crates/ui-egui/src/i18n.rs`, `crates/ui-egui/locales/`, `docs/localization.md`, `docs/localization-zh-hans.md`, `docs/localization-ja.md` | One table entry per language (code, endonym, ISO 15924 script, catalog): English, Simplified Chinese and Japanese UI with a persisted language preference and craft-fonts regular/bold faces per script; menus, edit, crop/masks, settings, import/export and primary progress messages. Adding a language is a table entry plus two catalogs. Technical errors/release notes and date grouping headers remain English, and the web build embeds only the Japanese face. |
| LR-BEHAV-LEARN | Tutorials | OOS | 🚫 | | |
| LR-BEHAV-WHATSNEW | What's new | P2 | ✅ | `cmd:app.whatsNew`, `docs/whats-new.md` | Help ▸ What's New: release highlights |
diff --git a/xtask/src/parity.rs b/xtask/src/parity.rs
index 3e59a2013..321e3413c 100644
--- a/xtask/src/parity.rs
+++ b/xtask/src/parity.rs
@@ -442,5 +442,18 @@ old
fn reads_ui_command_ids() {
let src = "pub const UI_COMMANDS: &[UiCommand] = &[\n (\"view.detail\", \"Detail\", Some(\"D\"), \"View\"),\n (\"app.about\", \"About\", None, \"\"),\n];\nfn x() { (\"not.this\", 1); }";
assert_eq!(ui_command_ids(src), ["view.detail", "app.about"]);
+ let languages = "pub const LANGUAGE_COMMANDS: &[UiCommand] = &[\n (\"app.language.english\", Locale::En.name(), None, \"Edit>Language\"),\n];\n";
+ assert_eq!(ui_command_ids(&format!("{languages}{src}")), ["view.detail", "app.about", "app.language.english"]);
+ }
+
+ /// The real menu tables: both are found, so every language command is a known id.
+ #[test]
+ fn reads_the_language_commands_from_menus_rs() {
+ let menus = include_str!("../../crates/ui-egui/src/menus.rs");
+ let ids = ui_command_ids(menus);
+ for id in ["view.detail", "app.language.english", "app.language.japanese", "app.language.simplifiedChinese"] {
+ assert!(ids.iter().any(|known| known == id), "{id} not found");
+ }
+ assert_eq!(ids.iter().filter(|id| id.as_str() == "app.language.english").count(), 1, "one Language menu entry per language");
}
}