fix(ui): Screen Mode checks the current mode; Japanese View submenu paths

View › Screen Mode showed no check mark (checked() had no view.screenMode
arm), so with the Normal/Preview row gone nothing showed the current
mode. ja.rs still translated the old Type/Proof Setup, Type/Rotate Spread
and Type/Separations Preview paths; it now has the View/… paths,
Screen Mode, Extras and Structure included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
moppeeer 2026-10-12 00:09:46 +02:00 committed by paaspaas00
parent fb296eacac
commit 9ac6f522bb
2 changed files with 47 additions and 3 deletions

View File

@ -1550,15 +1550,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Type/Insert Special Character/Quotation Marks", "書式/特殊文字を挿入/引用符"),
("Type/Insert Special Character/Symbols", "書式/特殊文字を挿入/記号"),
("Type/Insert White Space", "書式/空白文字を挿入"),
("Type/Proof Setup", "書式/カラー校正設定"),
("Type/Rotate Spread", "書式/スプレッドを回転"),
("Type/Separations Preview", "書式/分版プレビュー"),
("Type/Story Direction", "書式/組み方向"),
("Type/Text Variables", "書式/テキスト変数"),
("Type/Track Changes", "書式/変更を記録"),
("Type/Type on a Path", "書式/パス上のテキスト"),
("View/Display Performance", "表示/表示品質"),
("View/Extras", "表示/表示補助"),
("View/Grids & Guides", "表示/グリッドとガイド"),
("View/Proof Setup", "表示/カラー校正設定"),
("View/Rotate Spread", "表示/スプレッドを回転"),
("View/Screen Mode", "表示/スクリーンモード"),
("View/Separations Preview", "表示/分版プレビュー"),
("View/Structure", "表示/構造"),
("Window/Arrange", "ウィンドウ/配置"),
("Window/Interactive", "ウィンドウ/インタラクティブ"),
("Window/Interface Color Theme", "ウィンドウ/インターフェイスのカラーテーマ"),

View File

@ -1793,6 +1793,17 @@ pub fn checked(app: &DesignApp, id: &str, params: &Value) -> Option<bool> {
"view.proofColors" => app.ui.proof_colors,
"view.flattenerPreview" => app.ui.flattener_preview,
"view.tagMarkers" => app.ui.tag_markers,
"view.screenMode" => {
let mode = match params.get("mode").and_then(Value::as_str) {
Some("normal") => crate::ScreenMode::Normal,
Some("preview") => crate::ScreenMode::Preview,
Some("bleed") => crate::ScreenMode::Bleed,
Some("slug") => crate::ScreenMode::Slug,
Some("presentation") => crate::ScreenMode::Presentation,
_ => return None,
};
app.ui.screen_mode == mode
}
"view.rotateSpread" => match params.get("angle").and_then(Value::as_i64) {
Some(0) => app.session.active().is_some_and(|st| st.doc.spreads.iter().all(|sp| sp.pages.first().is_none_or(|p| p.view_rotation == 0))),
_ => return None,
@ -2319,6 +2330,36 @@ mod tests {
assert_eq!(ui_label("view.togglePreview").and_then(|c| c.1), Some("W"));
}
/// The submenu paths of a menu bar menu ("View/Screen Mode"), as Edit › Menus keys them.
fn submenu_paths(title: &str) -> Vec<String> {
let items = MENUS.iter().find(|(t, _)| *t == title).map(|(_, items)| *items).unwrap_or_default();
let mut stack = vec![title.to_string()];
let mut out = Vec::new();
for e in items {
if let Some(name) = e.strip_prefix('>') {
let path = format!("{}/{name}", stack.last().map_or("", String::as_str));
out.push(path.clone());
stack.push(path);
} else if *e == "<" {
stack.pop();
}
}
out
}
#[test]
fn screen_mode_shows_the_current_mode_and_view_submenus_are_translated() {
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
let mode = |app: &DesignApp, m: &str| checked(app, "view.screenMode", &json!({ "mode": m }));
assert_eq!((mode(&app, "normal"), mode(&app, "preview")), (Some(true), Some(false)));
app.ui.screen_mode = crate::ScreenMode::Preview;
assert_eq!((mode(&app, "normal"), mode(&app, "preview")), (Some(false), Some(true)));
// Every View submenu has its Japanese path (Edit › Menus shows them).
for path in submenu_paths("View") {
assert_ne!(crate::i18n::tr("ja", &path), path, "{path} has no Japanese row");
}
}
fn walk(items: &[Item], out: &mut Vec<(String, String, Value)>) {
for it in items {
match it {