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)]
|
#[derive(Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
pub lang: String,
|
||||||
pub path_prefix: String,
|
pub path_prefix: String,
|
||||||
pub socket_address: SocketAddress,
|
pub socket_address: SocketAddress,
|
||||||
pub email_server: EmailServer,
|
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());
|
.store_solution(&captcha.chars_as_string());
|
||||||
|
|
||||||
let template = templates::ContactForm {
|
let template = templates::ContactForm {
|
||||||
|
base: templates::Base {
|
||||||
|
lang: ¶ms.config.lang,
|
||||||
path_prefix: ¶ms.config.path_prefix,
|
path_prefix: ¶ms.config.path_prefix,
|
||||||
|
},
|
||||||
was_validated: params.was_validated,
|
was_validated: params.was_validated,
|
||||||
id,
|
id,
|
||||||
name: params.name.unwrap_or_default(),
|
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");
|
info!("Successful contact form submission");
|
||||||
|
|
||||||
let template = templates::Success {
|
let template = templates::Success {
|
||||||
|
base: templates::Base {
|
||||||
|
lang: &config.lang,
|
||||||
path_prefix: &config.path_prefix,
|
path_prefix: &config.path_prefix,
|
||||||
|
},
|
||||||
message: &config.strings.success,
|
message: &config.strings.success,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,15 @@ use askama::Template;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
||||||
|
pub struct Base<'a> {
|
||||||
|
pub lang: &'a str,
|
||||||
|
pub path_prefix: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "contact_form.askama.html")]
|
#[template(path = "contact_form.askama.html")]
|
||||||
pub struct ContactForm<'a> {
|
pub struct ContactForm<'a> {
|
||||||
pub path_prefix: &'a str,
|
pub base: Base<'a>,
|
||||||
pub was_validated: bool,
|
pub was_validated: bool,
|
||||||
pub id: u16,
|
pub id: u16,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -20,6 +25,6 @@ pub struct ContactForm<'a> {
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "success.askama.html")]
|
#[template(path = "success.askama.html")]
|
||||||
pub struct Success<'a> {
|
pub struct Success<'a> {
|
||||||
pub path_prefix: &'a str,
|
pub base: Base<'a>,
|
||||||
pub message: &'a str,
|
pub message: &'a str,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="{{ base.lang }}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
{% block styles %}{% endblock %}
|
{% block styles %}{% endblock %}
|
||||||
|
|
||||||
<link href="{{ path_prefix }}/static/bootstrap/bootstrap.min.css"
|
<link href="{{ base.path_prefix }}/static/bootstrap/bootstrap.min.css"
|
||||||
rel="stylesheet"/>
|
rel="stylesheet"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -16,6 +16,6 @@
|
||||||
|
|
||||||
{% block scripts %}{% endblock %}
|
{% 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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<h2>{{ strings.title }}</h2>
|
<h2>{{ strings.title }}</h2>
|
||||||
|
|
||||||
<form id="contact-form"
|
<form id="contact-form"
|
||||||
action="{{ path_prefix }}/"
|
action="{{ base.path_prefix }}/"
|
||||||
method="post"
|
method="post"
|
||||||
{% if was_validated %} class="was-validated"{% endif %}
|
{% if was_validated %} class="was-validated"{% endif %}
|
||||||
novalidate>
|
novalidate>
|
||||||
|
@ -42,7 +42,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<label for="message" class="form-label">{{ strings.message_field.label }}</label>
|
<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 class="invalid-feedback">{{ strings.message_field.invalid_feedback }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue