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

View file

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

View file

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

View file

@ -217,7 +217,11 @@ impl L10n {
L10nOp::None => None, L10nOp::None => None,
L10nOp::Text(text) => Some(text.to_owned()), L10nOp::Text(text) => Some(text.to_owned()),
L10nOp::Translate(key) => match self.locales { L10nOp::Translate(key) => match self.locales {
Some(locales) => locales.lookup_with_args( Some(locales) => {
if self.args.is_empty() {
locales.try_lookup(langid, key)
} else {
locales.try_lookup_with_args(
langid, langid,
key, key,
&self &self
@ -227,7 +231,9 @@ impl L10n {
args.insert(key.to_string(), value.to_owned().into()); args.insert(key.to_string(), value.to_owned().into());
args args
}), }),
), )
}
}
None => None, None => None,
}, },
} }
@ -244,8 +250,17 @@ impl ToString for L10n {
L10nOp::None => "".to_owned(), L10nOp::None => "".to_owned(),
L10nOp::Text(text) => text.to_owned(), L10nOp::Text(text) => text.to_owned(),
L10nOp::Translate(key) => match self.locales { L10nOp::Translate(key) => match self.locales {
Some(locales) => locales Some(locales) => {
.lookup_with_args( 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() { match key.as_str() {
LANGUAGE_SET_FAILURE => &LANGID_FALLBACK, LANGUAGE_SET_FAILURE => &LANGID_FALLBACK,
_ => &LANGID_DEFAULT, _ => &LANGID_DEFAULT,
@ -259,8 +274,9 @@ impl ToString for L10n {
args args
}), }),
) )
.unwrap_or(key.to_owned()), }
None => key.to_owned(), }
None => format!("Unknown localization {}", key),
}, },
} }
} }