From 237c09966cc05f5aeeedfd93ef342dc8ff52eba2 Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 1 Sep 2024 19:04:08 +0300 Subject: Gettextize and add Russian translation This is a very shitty translation, but it can be improved later. I added it mostly as a test for translations working correctly, since I know Russian and might as well translate the app into the language. --- src/components/post_editor.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/components/post_editor.rs') diff --git a/src/components/post_editor.rs b/src/components/post_editor.rs index 534b0dd..d1a6cf0 100644 --- a/src/components/post_editor.rs +++ b/src/components/post_editor.rs @@ -1,3 +1,4 @@ +use gettextrs::*; use crate::components; use crate::components::tag_pill::*; use adw::prelude::*; @@ -138,7 +139,7 @@ impl Component for Post #[name = "name_label"] gtk::Label { - set_markup: "Name", + set_markup: &gettext("Name"), set_margin_horizontal: 10, set_halign: gtk::Align::Start, set_valign: gtk::Align::Center, @@ -153,7 +154,7 @@ impl Component for Post #[name = "summary_label"] gtk::Label { - set_markup: "Summary", + set_markup: &gettext("Summary"), set_margin_horizontal: 10, set_halign: gtk::Align::Start, set_valign: gtk::Align::Center, @@ -175,7 +176,7 @@ impl Component for Post #[name = "tag_label"] gtk::Label { - set_markup: "Tags", + set_markup: &gettext("Tags"), set_margin_horizontal: 10, set_halign: gtk::Align::Start, set_valign: gtk::Align::Center, @@ -223,7 +224,7 @@ impl Component for Post #[name = "content_label"] gtk::Label { - set_markup: "Content", + set_markup: &gettext("Content"), set_halign: gtk::Align::Start, set_valign: gtk::Align::Start, set_margin_vertical: 10, @@ -276,7 +277,7 @@ impl Component for Post #[name = "visibility_label"] gtk::Label { - set_markup: "Visibility", + set_markup: &gettext("Visibility"), set_halign: gtk::Align::Start, set_valign: gtk::Align::Start, set_margin_vertical: 10, @@ -373,7 +374,7 @@ impl Component for Post [] as [gtk::Expression; 0], glib::closure::RustClosure::new(|v| { let list_item = v[0].get::().unwrap(); - Some(list_item.name().into()) + Some(gettext(list_item.name().as_str()).into()) }) ) )); @@ -489,7 +490,7 @@ impl Component for Post Input::SmartSummary(components::SmartSummaryOutput::Error(err)) => { self.set_smart_summary_busy_guard(None); - let toast = adw::Toast::new(&format!("Smart Summary error: {}", err)); + let toast = adw::Toast::new(&gettext!("Smart Summary error: {}", err)); toast.set_timeout(0); toast.set_priority(adw::ToastPriority::High); root.add_toast(toast); @@ -536,8 +537,8 @@ impl Component for Post self.summary_buffer.set_text(""); self.tags.guard().clear(); self.content_buffer.set_text(""); - let toast = adw::Toast::new("Post submitted"); - toast.set_button_label(Some("Open")); + let toast = adw::Toast::new(&gettext("Post submitted")); + toast.set_button_label(Some(&gettext("Open"))); toast.connect_button_clicked(move |toast| { gtk::UriLauncher::new(&location.to_string()).launch( None::<&adw::ApplicationWindow>, @@ -555,7 +556,7 @@ impl Component for Post root.add_toast(toast); }, Input::SubmitError(err) => { - let toast = adw::Toast::new(&format!("Error sending post: {}", err)); + let toast = adw::Toast::new(&gettext!("Error sending post: {}", err)); toast.set_timeout(0); toast.set_priority(adw::ToastPriority::High); -- cgit 1.4.1