Translate Rust strings

This commit is contained in:
Bat 2018-06-17 17:06:47 +01:00
parent ab841f826d
commit 152eafc06f
7 changed files with 104 additions and 6 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ rls
**/*.rs.bk
rls
translations
po/*.po~

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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<User>) -> 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())
}))
}
}

View File

@ -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<LoginForm>, flash: Option<FlashMessage>, 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<LoginForm>, flash: Option<FlashMessage>, 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)))

View File

@ -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<Redirect> {
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)
}