fix localization

This commit is contained in:
nludwig 2026-02-02 15:20:28 -08:00
parent d5f1ac4e91
commit cc27b6ab30
3 changed files with 75 additions and 51 deletions

View file

@ -62,6 +62,30 @@ advanced = Advanced
show-headerbar = Show header show-headerbar = Show header
show-header-description = Reveal the header from the right-click menu. show-header-description = Reveal the header from the right-click menu.
### Keyboard shortcuts
keyboard-shortcuts = Keyboard shortcuts
customize-shortcuts = Customize shortcuts
shortcut-capture-hint = Press new shortcut, or Esc to cancel
cancel = Cancel
no-shortcuts = No shortcuts
add-shortcut = + Add
shortcut-group-clipboard = Clipboard
shortcut-group-tabs = Tabs
shortcut-group-window = Window
shortcut-group-zoom = Zoom
shortcut-group-other = Other
unbind = Unbind
copy-or-sigint = Copy or SIGINT
paste-primary = Paste primary
focus-pane-left = Focus pane left
focus-pane-right = Focus pane right
focus-pane-up = Focus pane up
focus-pane-down = Focus pane down
toggle-fullscreen = Toggle fullscreen
close-window = Close window
password-manager = Password manager
tab-activate = Activate tab { $number }
# Find # Find
find-placeholder = Find... find-placeholder = Find...
find-previous = Find previous find-previous = Find previous

View file

@ -1286,9 +1286,9 @@ impl App {
); );
let mut shortcuts_section = widget::settings::section() let mut shortcuts_section = widget::settings::section()
.title("Keyboard shortcuts") .title(fl!("keyboard-shortcuts"))
.add( .add(
widget::settings::item::builder("Customize shortcuts").control( widget::settings::item::builder(fl!("customize-shortcuts")).control(
if self.show_keyboard_shortcuts { if self.show_keyboard_shortcuts {
widget::button::custom(icon_cache_get("go-up-symbolic", 16)) widget::button::custom(icon_cache_get("go-up-symbolic", 16))
.on_press(Message::KeyboardShortcuts(false)) .on_press(Message::KeyboardShortcuts(false))
@ -1314,10 +1314,10 @@ impl App {
if self.shortcut_capture == Some(action) { if self.shortcut_capture == Some(action) {
rows.push( rows.push(
widget::row::with_children(vec![ widget::row::with_children(vec![
widget::text::body("Press new shortcut, or Esc to cancel") widget::text::body(fl!("shortcut-capture-hint"))
.into(), .into(),
widget::horizontal_space().into(), widget::horizontal_space().into(),
widget::button::standard("Cancel") widget::button::standard(fl!("cancel"))
.on_press(Message::ShortcutCaptureCancel) .on_press(Message::ShortcutCaptureCancel)
.into(), .into(),
]) ])
@ -1327,7 +1327,7 @@ impl App {
} }
if bindings.is_empty() { if bindings.is_empty() {
rows.push(widget::text::body("No shortcuts").into()); rows.push(widget::text::body(fl!("no-shortcuts")).into());
} else { } else {
for resolved in bindings { for resolved in bindings {
let binding_text = widget::text::body( let binding_text = widget::text::body(
@ -1363,7 +1363,7 @@ impl App {
rows.push( rows.push(
widget::row::with_children(vec![ widget::row::with_children(vec![
widget::horizontal_space().into(), widget::horizontal_space().into(),
widget::button::standard("+ Add") widget::button::standard(fl!("add-shortcut"))
.on_press(Message::ShortcutCaptureStart(action)) .on_press(Message::ShortcutCaptureStart(action))
.into(), .into(),
]) ])

View file

@ -8,7 +8,7 @@ use cosmic::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use crate::Action; use crate::{Action, fl};
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub enum ModifierName { pub enum ModifierName {
@ -227,56 +227,56 @@ impl ShortcutsConfig {
} }
} }
pub fn action_label(action: KeyBindAction) -> &'static str { pub fn action_label(action: KeyBindAction) -> String {
match action { match action {
KeyBindAction::Unbind => "Unbind", KeyBindAction::Unbind => fl!("unbind"),
KeyBindAction::ClearScrollback => "Clear scrollback", KeyBindAction::ClearScrollback => fl!("clear-scrollback"),
KeyBindAction::Copy => "Copy", KeyBindAction::Copy => fl!("copy"),
KeyBindAction::CopyOrSigint => "Copy or SIGINT", KeyBindAction::CopyOrSigint => fl!("copy-or-sigint"),
KeyBindAction::Find => "Find", KeyBindAction::Find => fl!("find"),
KeyBindAction::PaneFocusDown => "Focus pane down", KeyBindAction::PaneFocusDown => fl!("focus-pane-down"),
KeyBindAction::PaneFocusLeft => "Focus pane left", KeyBindAction::PaneFocusLeft => fl!("focus-pane-left"),
KeyBindAction::PaneFocusRight => "Focus pane right", KeyBindAction::PaneFocusRight => fl!("focus-pane-right"),
KeyBindAction::PaneFocusUp => "Focus pane up", KeyBindAction::PaneFocusUp => fl!("focus-pane-up"),
KeyBindAction::PaneSplitHorizontal => "Split pane horizontally", KeyBindAction::PaneSplitHorizontal => fl!("split-horizontal"),
KeyBindAction::PaneSplitVertical => "Split pane vertically", KeyBindAction::PaneSplitVertical => fl!("split-vertical"),
KeyBindAction::PaneToggleMaximized => "Toggle pane maximized", KeyBindAction::PaneToggleMaximized => fl!("pane-toggle-maximize"),
KeyBindAction::Paste => "Paste", KeyBindAction::Paste => fl!("paste"),
KeyBindAction::PastePrimary => "Paste primary", KeyBindAction::PastePrimary => fl!("paste-primary"),
KeyBindAction::PasswordManager => "Password manager", KeyBindAction::PasswordManager => fl!("password-manager"),
KeyBindAction::SelectAll => "Select all", KeyBindAction::SelectAll => fl!("select-all"),
KeyBindAction::Settings => "Settings", KeyBindAction::Settings => fl!("settings"),
KeyBindAction::TabActivate0 => "Activate tab 1", KeyBindAction::TabActivate0 => fl!("tab-activate", number = 1),
KeyBindAction::TabActivate1 => "Activate tab 2", KeyBindAction::TabActivate1 => fl!("tab-activate", number = 2),
KeyBindAction::TabActivate2 => "Activate tab 3", KeyBindAction::TabActivate2 => fl!("tab-activate", number = 3),
KeyBindAction::TabActivate3 => "Activate tab 4", KeyBindAction::TabActivate3 => fl!("tab-activate", number = 4),
KeyBindAction::TabActivate4 => "Activate tab 5", KeyBindAction::TabActivate4 => fl!("tab-activate", number = 5),
KeyBindAction::TabActivate5 => "Activate tab 6", KeyBindAction::TabActivate5 => fl!("tab-activate", number = 6),
KeyBindAction::TabActivate6 => "Activate tab 7", KeyBindAction::TabActivate6 => fl!("tab-activate", number = 7),
KeyBindAction::TabActivate7 => "Activate tab 8", KeyBindAction::TabActivate7 => fl!("tab-activate", number = 8),
KeyBindAction::TabActivate8 => "Activate tab 9", KeyBindAction::TabActivate8 => fl!("tab-activate", number = 9),
KeyBindAction::TabClose => "Close tab", KeyBindAction::TabClose => fl!("close-tab"),
KeyBindAction::TabNew => "New tab", KeyBindAction::TabNew => fl!("new-tab"),
KeyBindAction::TabNext => "Next tab", KeyBindAction::TabNext => fl!("next-tab"),
KeyBindAction::TabPrev => "Previous tab", KeyBindAction::TabPrev => fl!("previous-tab"),
KeyBindAction::ToggleFullscreen => "Toggle fullscreen", KeyBindAction::ToggleFullscreen => fl!("toggle-fullscreen"),
KeyBindAction::WindowClose => "Close window", KeyBindAction::WindowClose => fl!("close-window"),
KeyBindAction::WindowNew => "New window", KeyBindAction::WindowNew => fl!("new-window"),
KeyBindAction::ZoomIn => "Zoom in", KeyBindAction::ZoomIn => fl!("zoom-in"),
KeyBindAction::ZoomOut => "Zoom out", KeyBindAction::ZoomOut => fl!("zoom-out"),
KeyBindAction::ZoomReset => "Reset zoom", KeyBindAction::ZoomReset => fl!("zoom-reset"),
} }
} }
pub struct ShortcutGroup { pub struct ShortcutGroup {
pub title: &'static str, pub title: String,
pub actions: Vec<KeyBindAction>, pub actions: Vec<KeyBindAction>,
} }
pub fn shortcut_groups() -> Vec<ShortcutGroup> { pub fn shortcut_groups() -> Vec<ShortcutGroup> {
let mut groups = Vec::new(); let mut groups = Vec::new();
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Clipboard", title: fl!("shortcut-group-clipboard"),
actions: vec![ actions: vec![
KeyBindAction::SelectAll, KeyBindAction::SelectAll,
KeyBindAction::Copy, KeyBindAction::Copy,
@ -287,7 +287,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
], ],
}); });
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Tabs", title: fl!("shortcut-group-tabs"),
actions: vec![ actions: vec![
KeyBindAction::TabNew, KeyBindAction::TabNew,
KeyBindAction::TabClose, KeyBindAction::TabClose,
@ -305,7 +305,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
], ],
}); });
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Splits", title: fl!("splits"),
actions: vec![ actions: vec![
KeyBindAction::PaneSplitHorizontal, KeyBindAction::PaneSplitHorizontal,
KeyBindAction::PaneSplitVertical, KeyBindAction::PaneSplitVertical,
@ -317,7 +317,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
], ],
}); });
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Window", title: fl!("shortcut-group-window"),
actions: vec![ actions: vec![
KeyBindAction::WindowNew, KeyBindAction::WindowNew,
KeyBindAction::WindowClose, KeyBindAction::WindowClose,
@ -326,7 +326,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
], ],
}); });
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Zoom", title: fl!("shortcut-group-zoom"),
actions: vec![ actions: vec![
KeyBindAction::ZoomIn, KeyBindAction::ZoomIn,
KeyBindAction::ZoomOut, KeyBindAction::ZoomOut,
@ -337,7 +337,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
#[cfg(feature = "password_manager")] #[cfg(feature = "password_manager")]
other_actions.push(KeyBindAction::PasswordManager); other_actions.push(KeyBindAction::PasswordManager);
groups.push(ShortcutGroup { groups.push(ShortcutGroup {
title: "Other", title: fl!("shortcut-group-other"),
actions: other_actions, actions: other_actions,
}); });
groups groups