1
0
Fork 0
This commit is contained in:
Alex Kotov 2020-10-21 09:14:48 +05:00
parent e8593b5f5a
commit 076cc98098
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
6 changed files with 18 additions and 8 deletions

View file

@ -1 +1 @@
hello-world = Hello, World!
fedihub = FediHub

View file

@ -1 +1 @@
hello-world = Привет, Мир!
fedihub = FediHub

View file

@ -50,4 +50,12 @@ impl I18n {
Ok(Self(hash_map))
}
pub fn dummy_translate(&self, locale: &str, key: &str) -> String {
let bundle = self.0.get(locale).unwrap();
let msg = bundle.get_message(key).unwrap();
let val = msg.value.unwrap();
let mut errors = vec![];
bundle.format_pattern(val, None, &mut errors).to_string()
}
}

View file

@ -10,13 +10,17 @@ use rocket_csrf::CsrfToken;
#[get("/")]
pub fn index(
_i18n: State<I18n>,
i18n: State<I18n>,
csrf_token: CsrfToken,
current_user: states::MaybeCurrentUser,
) -> Result<Template, CommonResponse> {
let page_context = views::home::Index {
i18n_fedihub: i18n.dummy_translate("en", "fedihub"),
};
let context = views::Site {
page: "home/index".to_string(),
page_context: (),
page_context,
authenticity_token: csrf_token.authenticity_token().to_string(),
current_user: current_user.0,
};

View file

@ -16,11 +16,9 @@ pub struct Error {
}
pub mod home {
use crate::models;
#[derive(Serialize)]
pub struct Index {
pub users: Vec<models::User>,
pub i18n_fedihub: String,
}
}

View file

@ -1,6 +1,6 @@
<div class="jumbotron jumbotron-fluid text-center">
<div class="container">
<h1>FediHub</h1>
<h1>{{ i18n_fedihub }}</h1>
<p class="lead">Federated services without censorship.</p>
</div>
</div>