macOS: the menu bar follows the interface language at once

The system menu bar was built once at launch, so Edit › Interface
Language changed the panels but left the menus in the old language
until the next launch. It is rebuilt when the language changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013phQ3ekq6uGBEWD6FjFYG2
This commit is contained in:
con3code
2026-10-11 07:49:21 +09:00
co-authored by Claude Opus 5.5
parent a127c6d5c3
commit cc12ea576f
+8 -1
View File
@@ -20,6 +20,8 @@ pub struct NativeMenu {
_menu: Menu,
items: HashMap<String, (String, Value, Handle)>,
last_refresh: f64,
/// The interface language the titles are in: the menu is rebuilt when it changes.
language: String,
}
/// Accelerator for "Cmd+Shift+]" (modifier-less shortcuts stay in the app so typing works).
@@ -69,7 +71,7 @@ impl NativeMenu {
(p.is_null() && accel(sc).is_some()).then(|| id.clone())
})
.collect();
Self { _menu: menu, items, last_refresh: 0.0 }
Self { _menu: menu, items, last_refresh: 0.0, language: app.ui.language.clone() }
}
pub fn poll(&mut self, app: &mut DesignApp, ctx: &egui::Context) {
@@ -78,6 +80,11 @@ impl NativeMenu {
menus::activate_native(app, ctx, &cmd.clone(), &params.clone());
}
}
// Edit › Interface Language: the system menu bar follows at once, like the panels (the
// new menu replaces the old one as the application's menu before that one is dropped).
if app.ui.language != self.language {
*self = Self::install(app);
}
let now = designcraft_ui_egui::now_ms();
if now - self.last_refresh < 250.0 {
return;