🔖 [pagetop] release development version 0.0.51

This commit is contained in:
Manuel Cillero 2024-03-08 23:37:59 +01:00
parent c174ab4889
commit d0fcd12b81
4 changed files with 51 additions and 37 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "pagetop"
version = "0.0.50"
version = "0.0.51"
edition = "2021"
authors = [
@ -40,7 +40,7 @@ sqlite = ["database", "sea-orm/sqlx-sqlite"]
[dependencies]
async-trait = "0.1.77"
chrono = "0.4.33"
chrono = "0.4.35"
concat-string = "1.0.1"
figlet-rs = "0.1.5"
itoa = "1.0.10"
@ -57,7 +57,7 @@ tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] }
tracing-actix-web = "0.7.9"
fluent-templates = "0.8.0"
fluent-templates = "0.9.0"
unic-langid = { version = "0.9.4", features = ["macros"] }
actix-web = "4"
@ -79,13 +79,13 @@ optional = true
version = "0.4.1"
[dependencies.sea-orm]
version = "0.12.9"
version = "0.12.14"
features = ["debug-print", "macros", "runtime-async-std-native-tls"]
default-features = false
optional = true
[dependencies.sea-schema]
version = "0.14.1"
version = "0.14.2"
optional = true
[build-dependencies]

View file

@ -1,11 +1,10 @@
use crate::prelude::*;
#[derive(AutoDefault)]
pub struct Error403;
impl ComponentTrait for Error403 {
fn new() -> Self {
Error403::default()
Error403
}
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {

View file

@ -1,11 +1,10 @@
use crate::prelude::*;
#[derive(AutoDefault)]
pub struct Error404;
impl ComponentTrait for Error404 {
fn new() -> Self {
Error404::default()
Error404
}
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {

View file

@ -217,17 +217,23 @@ impl L10n {
L10nOp::None => None,
L10nOp::Text(text) => Some(text.to_owned()),
L10nOp::Translate(key) => match self.locales {
Some(locales) => locales.lookup_with_args(
langid,
key,
&self
.args
.iter()
.fold(HashMap::new(), |mut args, (key, value)| {
args.insert(key.to_string(), value.to_owned().into());
args
}),
),
Some(locales) => {
if self.args.is_empty() {
locales.try_lookup(langid, key)
} else {
locales.try_lookup_with_args(
langid,
key,
&self
.args
.iter()
.fold(HashMap::new(), |mut args, (key, value)| {
args.insert(key.to_string(), value.to_owned().into());
args
}),
)
}
}
None => None,
},
}
@ -244,23 +250,33 @@ impl ToString for L10n {
L10nOp::None => "".to_owned(),
L10nOp::Text(text) => text.to_owned(),
L10nOp::Translate(key) => match self.locales {
Some(locales) => locales
.lookup_with_args(
match key.as_str() {
LANGUAGE_SET_FAILURE => &LANGID_FALLBACK,
_ => &LANGID_DEFAULT,
},
key,
&self
.args
.iter()
.fold(HashMap::new(), |mut args, (key, value)| {
args.insert(key.to_string(), value.to_owned().into());
args
}),
)
.unwrap_or(key.to_owned()),
None => key.to_owned(),
Some(locales) => {
if self.args.is_empty() {
locales.lookup(
match key.as_str() {
LANGUAGE_SET_FAILURE => &LANGID_FALLBACK,
_ => &LANGID_DEFAULT,
},
key,
)
} else {
locales.lookup_with_args(
match key.as_str() {
LANGUAGE_SET_FAILURE => &LANGID_FALLBACK,
_ => &LANGID_DEFAULT,
},
key,
&self
.args
.iter()
.fold(HashMap::new(), |mut args, (key, value)| {
args.insert(key.to_string(), value.to_owned().into());
args
}),
)
}
}
None => format!("Unknown localization {}", key),
},
}
}