Translate Rust strings
This commit is contained in:
@@ -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())
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)))
|
||||
|
||||
+2
-1
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user