Browse Source

i18n

merge-requests/2138/head
Pavel Shirshov 2 months ago
parent
commit
7069b9130f
  1. 21
      src/tray.rs

21
src/tray.rs

@ -1,8 +1,9 @@
use gettextrs::gettext;
use ksni::{menu::StandardItem, Icon, MenuItem, Tray, TrayMethods};
use tokio::sync::mpsc;
use tracing::{info, warn};
use crate::RUNTIME;
use crate::{RUNTIME, gettext_f};
#[derive(Debug)]
pub enum TrayCommand {
@ -73,7 +74,7 @@ impl Tray for FractalTray {
}
fn title(&self) -> String {
"Fractal".to_string()
gettext("Fractal")
}
fn id(&self) -> String {
@ -97,15 +98,16 @@ impl Tray for FractalTray {
}
fn tool_tip(&self) -> ksni::ToolTip {
let app_name = gettext("Fractal");
let description = if self.has_unread {
"Unread messages"
gettext("Unread messages")
} else {
"Fractal"
app_name.clone()
};
ksni::ToolTip {
icon_name: self.icon_name(),
title: "Fractal".to_string(),
description: description.to_string(),
title: app_name,
description,
..Default::default()
}
}
@ -116,11 +118,14 @@ impl Tray for FractalTray {
}
fn menu(&self) -> Vec<MenuItem<Self>> {
let app_name = gettext("Fractal");
let show_label = gettext_f("Show {app_name}", &[("app_name", app_name.as_str())]);
let quit_label = gettext("Quit");
let tx_show = self.tx.clone();
let tx_quit = self.tx.clone();
vec![
StandardItem {
label: "Show Fractal".into(),
label: show_label.into(),
activate: Box::new(move |_| {
info!("Tray menu: Show clicked");
let _ = tx_show.send(TrayCommand::Show);
@ -130,7 +135,7 @@ impl Tray for FractalTray {
.into(),
MenuItem::Separator,
StandardItem {
label: "Quit".into(),
label: quit_label.into(),
activate: Box::new(move |_| {
info!("Tray menu: Quit clicked");
let _ = tx_quit.send(TrayCommand::Quit);

Loading…
Cancel
Save