Add language switching, fix logout

This commit is contained in:
2021-08-12 15:48:02 +02:00
committed by dietrich
parent fa924a8e8c
commit 0a23b786b0
16 changed files with 220 additions and 85 deletions
+25 -1
View File
@@ -1,6 +1,7 @@
use std::ops::Deref;
use serde::{Deserialize, Serialize, Serializer};
use strum_macros::{AsRefStr, EnumIter, EnumString, ToString};
/// A generic list returntype containing the User and a Vec containing e.g. Links or Users
#[derive(Clone, Deserialize, Serialize)]
pub struct ListWithOwner<T> {
@@ -23,7 +24,7 @@ pub struct User {
pub email: String,
pub password: Secret,
pub role: i64,
pub language: String,
pub language: Lang,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
@@ -105,3 +106,26 @@ impl<T> Deref for Loadable<T> {
}
}
}
/// An `enum` containing the available languages.
/// To add an additional language add it to this enum aswell as an appropriate file into the locales folder.
#[allow(clippy::upper_case_acronyms)]
#[derive(
Debug,
Copy,
Clone,
EnumIter,
EnumString,
ToString,
AsRefStr,
Eq,
PartialEq,
Serialize,
Deserialize,
)]
pub enum Lang {
#[strum(serialize = "en-US", serialize = "en", serialize = "enUS")]
EnUS,
#[strum(serialize = "de-DE", serialize = "de", serialize = "deDE")]
DeDE,
}