🔖 [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,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),
},
}
}