2 languages
This commit is contained in:
35
src/game.rs
35
src/game.rs
@@ -30,27 +30,32 @@ async fn index(
|
||||
page.messages(messages);
|
||||
let markup = page.content(html! {
|
||||
hgroup {
|
||||
h1 { "Who finds the most cameras?" }
|
||||
h1 { (t!("game_title")) }
|
||||
}
|
||||
p {
|
||||
mark { "TODO: Explanation of AEF / digital shadows / search game" }
|
||||
mark { (t!("game_explanation_todo")) }
|
||||
}
|
||||
|
||||
div.mb-sm { (t!("ask_to_change_name", name = client.get_display_name())) }
|
||||
|
||||
form action="/name" method="post" {
|
||||
fieldset role="group" {
|
||||
input name="name" placeholder=(t!("funny_name_change_placeholder")) aria-label="Name" required;
|
||||
input type="submit" value="Save";
|
||||
input
|
||||
name="name"
|
||||
placeholder=(t!("funny_name_change_placeholder"))
|
||||
aria-label="Name"
|
||||
required;
|
||||
input type="submit" value=(t!("save_button"));
|
||||
}
|
||||
}
|
||||
|
||||
p.mb-0 {
|
||||
"You have found "
|
||||
(sightings.len())
|
||||
"/"
|
||||
(amount_total_cameras)
|
||||
" cameras:"
|
||||
({
|
||||
t!(
|
||||
"cameras_found", found = sightings.len(), total =
|
||||
amount_total_cameras
|
||||
)
|
||||
})
|
||||
progress value=(sightings.len()) max=(amount_total_cameras);
|
||||
}
|
||||
|
||||
@@ -61,7 +66,7 @@ async fn index(
|
||||
}
|
||||
|
||||
p {
|
||||
h2 { "Highscore" }
|
||||
h2 { (t!("highscore_title")) }
|
||||
ul.iterated {
|
||||
@for rank in highscore {
|
||||
li.card {
|
||||
@@ -105,7 +110,7 @@ async fn game(
|
||||
if let Ok(number) = backend.client_found_camera(&client, &camera).await {
|
||||
messages.info(format!("found-cam|{}|{number}", camera.name));
|
||||
} else {
|
||||
messages.info("err|Try to find a new camera!|You have already collected this camera.|");
|
||||
messages.info(&format!("err|{}|{}|{}", t!("error_already_found_title"), t!("error_already_found_body"), t!("error_already_found_footer")));
|
||||
}
|
||||
|
||||
Ok(Redirect::to("/game"))
|
||||
@@ -114,7 +119,7 @@ async fn game(
|
||||
async fn not_found(cookies: CookieJar, headers: HeaderMap) -> Markup {
|
||||
let lang = language(&cookies, &headers);
|
||||
Page::new(lang).content(html! {
|
||||
h1 { "uups" }
|
||||
h1 { (t!("not_found_title")) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -133,9 +138,9 @@ async fn set_name(
|
||||
|
||||
match backend.set_client_name(&client, &form.name).await {
|
||||
Ok(()) => messages.info("set-name-succ"),
|
||||
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!("err|That's too little!|We need more information about you. Give us at least {expected} characters for you new name!|Received characters: {actual}")),
|
||||
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!("err|That's too much!|We only live in (20)25, so please use less than {expected} characters for your new name.|Received characters: {actual}")),
|
||||
Err(NameUpdateError::ContainsBadWord) => messages.info(format!("err|Hmmm. I don't like this name.|Please choose a different one!|")),
|
||||
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_short_title"), t!("error_name_too_short_body", expected = expected), t!("received_characters"), actual)),
|
||||
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_long_title"), t!("error_name_too_long_body", expected = expected), t!("received_characters"), actual)),
|
||||
Err(NameUpdateError::ContainsBadWord) => messages.info(format!("err|{}|{}|{}", t!("error_bad_word_title"), t!("error_bad_word_body"), t!("error_bad_word_footer"))),
|
||||
};
|
||||
|
||||
// Redirect back to the game page
|
||||
|
Reference in New Issue
Block a user