#Changing Window Menu?

1 messages · Page 1 of 1 (latest)

mild oyster
#

Hello all, I'd like to change the displayed text in my app's window menu (built using https://tauri.app/v1/guides/features/menu/#listening-to-events-on-custom-menu-items). Is there a way to do this? Let's say for example I have my app's menu with multiple options in English and then I select, inside my app's settings, an option to switch over to Spanish, which would change the strings displayed in the menu. Is there a way to do this?

languid ether
#

you can use following code in tauri v1 :
#[tauri::command]
pub fn change_menu_title(window: tauri::Window, id: String, title: String) -> Option<String> {
let menu_handle = window.menu_handle();
std:🧵:spawn(move || {
menu_handle.get_item(&id).set_title(title).expect("Failed");
});

Some("OK".to_string())

}

if you are using tauri 2.0, here is a better example:
https://github.com/zitiger/markhu/blob/ff4e816f40398d22281076af23538031f162d4e1/src-tauri/src/menu.rs#L168

GitHub

Contribute to zitiger/markhu development by creating an account on GitHub.