diff --git a/pagetop/src/core/module/definition.rs b/pagetop/src/core/module/definition.rs index 775b4b5a..a353c430 100644 --- a/pagetop/src/core/module/definition.rs +++ b/pagetop/src/core/module/definition.rs @@ -19,7 +19,7 @@ pub trait ModuleTrait: HasHandle + ModuleBase + Send + Sync { } fn description(&self) -> L10n { - L10n::default() + L10n::none() } fn theme(&self) -> Option { diff --git a/pagetop/src/html/opt_translated.rs b/pagetop/src/html/opt_translated.rs index c2424e9e..722db440 100644 --- a/pagetop/src/html/opt_translated.rs +++ b/pagetop/src/html/opt_translated.rs @@ -1,36 +1,31 @@ use crate::fn_builder; -use crate::html::{html, Markup}; +use crate::html::Markup; use crate::locale::{L10n, LanguageIdentifier}; #[derive(Default)] -pub struct OptionTranslated(Option); + +pub struct OptionTranslated(L10n); impl OptionTranslated { pub fn new(value: L10n) -> Self { - OptionTranslated::default().with_value(value) + OptionTranslated(value) } // OptionTranslated BUILDER. #[fn_builder] pub fn alter_value(&mut self, value: L10n) -> &mut Self { - self.0 = Some(value); + self.0 = value; self } // OptionTranslated GETTERS. pub fn using(&self, langid: &LanguageIdentifier) -> Option { - if let Some(value) = &self.0 { - return value.using(langid); - } - None + self.0.using(langid) } pub fn escaped(&self, langid: &LanguageIdentifier) -> Markup { - match &self.0 { - Some(value) => value.escaped(langid), - _ => html! {}, - } + self.0.escaped(langid) } } diff --git a/pagetop/src/locale.rs b/pagetop/src/locale.rs index 81520c98..de2e1b8d 100644 --- a/pagetop/src/locale.rs +++ b/pagetop/src/locale.rs @@ -185,14 +185,13 @@ pub struct L10n { } impl L10n { + pub fn none() -> Self { + L10n::default() + } + pub fn n(text: impl Into) -> Self { - let text = text.into(); L10n { - op: if text.trim().is_empty() { - L10nOp::None - } else { - L10nOp::Text(text) - }, + op: L10nOp::Text(text.into()), ..Default::default() } }