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/signin.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/components/signin.rs') diff --git a/src/components/signin.rs b/src/components/signin.rs index 08e850a..156686e 100644 --- a/src/components/signin.rs +++ b/src/components/signin.rs @@ -1,3 +1,4 @@ +use gettextrs::*; use std::cell::RefCell; use adw::prelude::*; @@ -87,7 +88,7 @@ fn callback_handler(sender: AsyncComponentSender) -> impl Fn(&soup::Serv msg.set_response( Some("text/plain; charset=\"utf-8\""), soup::MemoryUse::Static, - "Thank you! This window can now be closed.".as_bytes() + gettext("Thank you! This window can now be closed.").as_bytes() ); msg.connect_finished(move |_| { sender.input(Input::Callback(Ok(response.take().unwrap()))); @@ -206,12 +207,12 @@ impl AsyncComponent for SignIn { gtk::Label { add_css_class: "title-1", - set_text: "Sign in", + set_text: &gettext("Sign in"), set_justify: gtk::Justification::Center, }, gtk::Label { - set_text: "Please sign in with your website to use Bowl.\nYour website needs to support IndieAuth and Micropub for this app to work.", + set_text: &gettext("Please sign in with your website to use Bowl.\nYour website needs to support IndieAuth and Micropub for this app to work."), set_wrap: true, set_halign: gtk::Align::BaselineCenter, set_valign: gtk::Align::BaselineCenter, @@ -240,12 +241,12 @@ impl AsyncComponent for SignIn { }, gtk::Label { #[watch] - set_text: if model.busy_guard.is_some() { - "Talking to your website..." + set_text: &if model.busy_guard.is_some() { + gettext("Talking to your website...") } else if model.callback_server.is_some() { - "Waiting for authorization..." + gettext("Waiting for authorization...") } else { - "Sign in" + gettext("Sign in") }, } }, @@ -451,7 +452,7 @@ impl AsyncComponent for SignIn { if res.state != self.state { return self.bail_out(widgets, sender, IndieauthError { kind: kittybox_indieauth::ErrorKind::InvalidRequest, - msg: Some("state doesn't match what we remember, ceremony aborted".to_owned()), + msg: Some(gettext("state doesn't match what we remember, ceremony aborted")), error_uri: None, }.into()) } @@ -459,7 +460,7 @@ impl AsyncComponent for SignIn { if res.iss != metadata.issuer { return self.bail_out(widgets, sender, IndieauthError { kind: kittybox_indieauth::ErrorKind::InvalidRequest, - msg: Some("issuer doesn't match what we remember, ceremony aborted".to_owned()), + msg: Some(gettext("issuer doesn't match what we remember, ceremony aborted")), error_uri: None, }.into()) } -- cgit 1.4.1