From 152eafc06fd6210ae9916b272cc4edfc264a38e7 Mon Sep 17 00:00:00 2001 From: Bat Date: Sun, 17 Jun 2018 17:06:47 +0100 Subject: [PATCH] Translate Rust strings --- .gitignore | 1 + po/en.po | 30 ++++++++++++++++++++++++++++++ po/fr.po | 38 ++++++++++++++++++++++++++++++++++++-- po/plume.pot | 30 ++++++++++++++++++++++++++++++ src/routes/instance.rs | 3 ++- src/routes/session.rs | 5 +++-- src/utils.rs | 3 ++- 7 files changed, 104 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 32bc127..a4c7fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ rls **/*.rs.bk rls translations +po/*.po~ diff --git a/po/en.po b/po/en.po index 0a57a9b..d65de4b 100644 --- a/po/en.po +++ b/po/en.po @@ -223,3 +223,33 @@ msgstr "" msgid "Register" msgstr "" + +msgid "You need to be logged in order to create a new blog" +msgstr "" + +msgid "You need to be logged in order to post a comment" +msgstr "" + +msgid "You need to be logged in order to like a post" +msgstr "" + +msgid "You need to be logged in order to see your notifications" +msgstr "" + +msgid "You need to be logged in order to write a new post" +msgstr "" + +msgid "You need to be logged in order to reshare a post" +msgstr "" + +msgid "Invalid username or password" +msgstr "" + +msgid "You need to be logged in order to access your dashboard" +msgstr "" + +msgid "You need to be logged in order to follow someone" +msgstr "" + +msgid "You need to be logged in order to edit your profile" +msgstr "" diff --git a/po/fr.po b/po/fr.po index c24f4e0..a4e6d81 100644 --- a/po/fr.po +++ b/po/fr.po @@ -46,7 +46,9 @@ msgid "Something broke on our side." msgstr "Nous avons cassé quelque chose" msgid "Sorry about that. If you think this is a bug, please report it." -msgstr "Nous sommes désolé⋅e⋅s. Si vous pensez que c'est un bogue, merci de le rapporter." +msgstr "" +"Nous sommes désolé⋅e⋅s. Si vous pensez que c'est un bogue, merci de le " +"rapporter." msgid "Configuration" msgstr "Configuration" @@ -131,7 +133,9 @@ msgid "Your Blogs" msgstr "Vos blogs" msgid "You don't have any blog yet. Create your own, or ask to join one." -msgstr "Vous n'avez pas encore de blog. Créez le votre, ou demandez à en rejoindre un." +msgstr "" +"Vous n'avez pas encore de blog. Créez le votre, ou demandez à en rejoindre " +"un." msgid "Start a new blog" msgstr "Commencez un nouveau blog" @@ -218,3 +222,33 @@ msgstr "Se connecter" msgid "Register" msgstr "S'inscrire" + +msgid "You need to be logged in order to create a new blog" +msgstr "" + +msgid "You need to be logged in order to post a comment" +msgstr "" + +msgid "You need to be logged in order to like a post" +msgstr "" + +msgid "You need to be logged in order to see your notifications" +msgstr "" + +msgid "You need to be logged in order to write a new post" +msgstr "" + +msgid "You need to be logged in order to reshare a post" +msgstr "" + +msgid "Invalid username or password" +msgstr "" + +msgid "You need to be logged in order to access your dashboard" +msgstr "" + +msgid "You need to be logged in order to follow someone" +msgstr "" + +msgid "You need to be logged in order to edit your profile" +msgstr "" diff --git a/po/plume.pot b/po/plume.pot index 7a6f0aa..7fc8caf 100644 --- a/po/plume.pot +++ b/po/plume.pot @@ -219,3 +219,33 @@ msgstr "" msgid "Register" msgstr "" +msgid "You need to be logged in order to create a new blog" +msgstr "" + +msgid "You need to be logged in order to post a comment" +msgstr "" + +msgid "You need to be logged in order to like a post" +msgstr "" + +msgid "You need to be logged in order to see your notifications" +msgstr "" + +msgid "You need to be logged in order to write a new post" +msgstr "" + +msgid "You need to be logged in order to reshare a post" +msgstr "" + +msgid "Invalid username or password" +msgstr "" + +msgid "You need to be logged in order to access your dashboard" +msgstr "" + +msgid "You need to be logged in order to follow someone" +msgstr "" + +msgid "You need to be logged in order to edit your profile" +msgstr "" + diff --git a/src/routes/instance.rs b/src/routes/instance.rs index e8fa9c5..f366a39 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -1,3 +1,4 @@ +use gettextrs::gettext; use rocket::{request::Form, response::Redirect}; use rocket_contrib::{Json, Template}; use serde_json; @@ -38,7 +39,7 @@ fn index(conn: DbConn, user: Option) -> Template { } None => { Template::render("errors/500", json!({ - "error_message": "You need to configure your instance before using it." + "error_message": gettext("You need to configure your instance before using it.".to_string()) })) } } diff --git a/src/routes/session.rs b/src/routes/session.rs index 2b72879..057e63b 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -1,3 +1,4 @@ +use gettextrs::gettext; use rocket::{ http::{Cookie, Cookies, uri::Uri}, response::{Redirect, status::NotFound}, @@ -42,7 +43,7 @@ fn create(conn: DbConn, data: Form, flash: Option, mut Some(usr) => Ok(usr), None => match User::find_local(&*conn, form.email_or_name.to_string()) { Some(usr) => Ok(usr), - None => Err("Invalid username or password") + None => Err(gettext("Invalid username or password")) } }; match user { @@ -54,7 +55,7 @@ fn create(conn: DbConn, data: Form, flash: Option, mut .unwrap_or("/".to_owned())) )) } else { - Err(NotFound(String::from("Invalid username or password"))) + Err(NotFound(gettext("Invalid username or password"))) } }, Err(e) => Err(NotFound(String::from(e))) diff --git a/src/utils.rs b/src/utils.rs index 5adac6d..e9463e1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,4 @@ +use gettextrs::gettext; use heck::CamelCase; use rocket::{ http::uri::Uri, @@ -15,5 +16,5 @@ pub fn make_actor_id(name: String) -> String { } pub fn requires_login(message: &str, url: &str) -> Flash { - Flash::new(Redirect::to(Uri::new(format!("/login?m={}", message))), "callback", url) + Flash::new(Redirect::to(Uri::new(format!("/login?m={}", gettext(message.to_string())))), "callback", url) }