Add lang
This commit is contained in:
parent
8ef73122e5
commit
adcc18f5a5
5 changed files with 26 additions and 9 deletions
|
@ -57,6 +57,7 @@ pub struct Strings {
|
|||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
pub lang: String,
|
||||
pub path_prefix: String,
|
||||
pub socket_address: SocketAddress,
|
||||
pub email_server: EmailServer,
|
||||
|
|
|
@ -46,7 +46,10 @@ pub async fn render_contact_form(params: IndexParams<'_>) -> Result<Response, er
|
|||
.store_solution(&captcha.chars_as_string());
|
||||
|
||||
let template = templates::ContactForm {
|
||||
base: templates::Base {
|
||||
lang: ¶ms.config.lang,
|
||||
path_prefix: ¶ms.config.path_prefix,
|
||||
},
|
||||
was_validated: params.was_validated,
|
||||
id,
|
||||
name: params.name.unwrap_or_default(),
|
||||
|
@ -124,7 +127,10 @@ pub async fn success(config: Arc<config::Config>) -> Result<Response, errors::Ap
|
|||
info!("Successful contact form submission");
|
||||
|
||||
let template = templates::Success {
|
||||
base: templates::Base {
|
||||
lang: &config.lang,
|
||||
path_prefix: &config.path_prefix,
|
||||
},
|
||||
message: &config.strings.success,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,10 +2,15 @@ use askama::Template;
|
|||
|
||||
use crate::config;
|
||||
|
||||
pub struct Base<'a> {
|
||||
pub lang: &'a str,
|
||||
pub path_prefix: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "contact_form.askama.html")]
|
||||
pub struct ContactForm<'a> {
|
||||
pub path_prefix: &'a str,
|
||||
pub base: Base<'a>,
|
||||
pub was_validated: bool,
|
||||
pub id: u16,
|
||||
pub name: String,
|
||||
|
@ -20,6 +25,6 @@ pub struct ContactForm<'a> {
|
|||
#[derive(Template)]
|
||||
#[template(path = "success.askama.html")]
|
||||
pub struct Success<'a> {
|
||||
pub path_prefix: &'a str,
|
||||
pub base: Base<'a>,
|
||||
pub message: &'a str,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="{{ base.lang }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
{% block styles %}{% endblock %}
|
||||
|
||||
<link href="{{ path_prefix }}/static/bootstrap/bootstrap.min.css"
|
||||
<link href="{{ base.path_prefix }}/static/bootstrap/bootstrap.min.css"
|
||||
rel="stylesheet"/>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -16,6 +16,6 @@
|
|||
|
||||
{% block scripts %}{% endblock %}
|
||||
|
||||
<script src="{{ path_prefix }}/static/bootstrap/bootstrap.bundle.min.js"></script>
|
||||
<script src="{{ base.path_prefix }}/static/bootstrap/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<h2>{{ strings.title }}</h2>
|
||||
|
||||
<form id="contact-form"
|
||||
action="{{ path_prefix }}/"
|
||||
action="{{ base.path_prefix }}/"
|
||||
method="post"
|
||||
{% if was_validated %} class="was-validated"{% endif %}
|
||||
novalidate>
|
||||
|
@ -42,7 +42,12 @@
|
|||
</div>
|
||||
<div class="mb-5">
|
||||
<label for="message" class="form-label">{{ strings.message_field.label }}</label>
|
||||
<textarea name="message" rows="5" class="form-control" id="message" style="resize: none;" required>{{ message }}</textarea>
|
||||
<textarea name="message"
|
||||
rows="5"
|
||||
class="form-control"
|
||||
id="message"
|
||||
style="resize: none"
|
||||
required>{{ message }}</textarea>
|
||||
<div class="invalid-feedback">{{ strings.message_field.invalid_feedback }}</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue