improv(keyboard): localize input sources with dgettext
This commit is contained in:
parent
a9d97b5f4d
commit
5b41a76da7
6 changed files with 24 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1650,6 +1650,7 @@ dependencies = [
|
||||||
"fontdb 0.16.2",
|
"fontdb 0.16.2",
|
||||||
"freedesktop-desktop-entry",
|
"freedesktop-desktop-entry",
|
||||||
"futures",
|
"futures",
|
||||||
|
"gettext-rs",
|
||||||
"hostname-validator",
|
"hostname-validator",
|
||||||
"hostname1-zbus",
|
"hostname1-zbus",
|
||||||
"i18n-embed",
|
"i18n-embed",
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ fontdb = "0.16.2"
|
||||||
fixed_decimal = "0.5.6"
|
fixed_decimal = "0.5.6"
|
||||||
mime = "0.3.17"
|
mime = "0.3.17"
|
||||||
rustix = "0.38.41"
|
rustix = "0.38.41"
|
||||||
|
gettext-rs = { version = "0.7.2", features = [
|
||||||
|
"gettext-system",
|
||||||
|
], optional = true }
|
||||||
|
|
||||||
[dependencies.cosmic-settings-subscriptions]
|
[dependencies.cosmic-settings-subscriptions]
|
||||||
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
|
git = "https://github.com/pop-os/cosmic-settings-subscriptions"
|
||||||
|
|
@ -95,6 +98,7 @@ optional = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["a11y", "dbus-config", "linux", "single-instance", "wgpu"]
|
default = ["a11y", "dbus-config", "linux", "single-instance", "wgpu"]
|
||||||
|
gettext = ["dep:gettext-rs"]
|
||||||
|
|
||||||
# Default features for Linux
|
# Default features for Linux
|
||||||
linux = [
|
linux = [
|
||||||
|
|
@ -120,6 +124,7 @@ page-bluetooth = ["dep:bluez-zbus", "dep:zbus"]
|
||||||
page-date = ["dep:timedate-zbus", "dep:zbus"]
|
page-date = ["dep:timedate-zbus", "dep:zbus"]
|
||||||
page-default-apps = ["dep:mime-apps"]
|
page-default-apps = ["dep:mime-apps"]
|
||||||
page-input = [
|
page-input = [
|
||||||
|
"gettext",
|
||||||
"dep:cosmic-comp-config",
|
"dep:cosmic-comp-config",
|
||||||
"dep:cosmic-settings-config",
|
"dep:cosmic-settings-config",
|
||||||
"dep:udev",
|
"dep:udev",
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,11 @@ pub fn main() -> color_eyre::Result<()> {
|
||||||
init_logger();
|
init_logger();
|
||||||
init_localizer();
|
init_localizer();
|
||||||
|
|
||||||
|
#[cfg(feature = "gettext")]
|
||||||
|
{
|
||||||
|
let _ = gettextrs::setlocale(gettextrs::LocaleCategory::LcAll, "");
|
||||||
|
}
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let settings = cosmic::app::Settings::default()
|
let settings = cosmic::app::Settings::default()
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
self.keyboard_layouts.insert((
|
self.keyboard_layouts.insert((
|
||||||
layout.name().to_owned(),
|
layout.name().to_owned(),
|
||||||
String::new(),
|
String::new(),
|
||||||
layout.description().to_owned(),
|
gettextrs::dgettext("xkeyboard-config", layout.description()),
|
||||||
source.clone(),
|
source.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -347,7 +347,7 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
(
|
(
|
||||||
layout.name().to_owned(),
|
layout.name().to_owned(),
|
||||||
variant.name().to_owned(),
|
variant.name().to_owned(),
|
||||||
variant.description().to_owned(),
|
gettextrs::dgettext("xkeyboard-config", variant.description()),
|
||||||
source.clone(),
|
source.clone(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -395,6 +395,13 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
|
self.active_layouts = Vec::new();
|
||||||
|
self.keyboard_layouts = SlotMap::new();
|
||||||
|
self.input_source_search = String::new();
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,7 @@ impl Model {
|
||||||
|
|
||||||
pub(super) fn on_clear(&mut self) {
|
pub(super) fn on_clear(&mut self) {
|
||||||
self.shortcut_models.clear();
|
self.shortcut_models.clear();
|
||||||
|
self.shortcut_models.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the custom configuration for keyboard shortcuts.
|
/// Gets the custom configuration for keyboard shortcuts.
|
||||||
|
|
|
||||||
|
|
@ -203,9 +203,9 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
fn on_leave(&mut self) -> Task<crate::pages::Message> {
|
||||||
self.search.actions.clear();
|
self.search.actions = SlotMap::new();
|
||||||
self.search.localized.clear();
|
self.search.localized = SecondaryMap::new();
|
||||||
self.search.input.clear();
|
self.search.input = String::new();
|
||||||
self.search_model.on_clear();
|
self.search_model.on_clear();
|
||||||
self.modified.custom = 0;
|
self.modified.custom = 0;
|
||||||
self.modified.manage_windows = 0;
|
self.modified.manage_windows = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue