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
+2 -1
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())
}))
}
}
+3 -2
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)))