🧑💻 Improve handling of empty translations
This commit is contained in:
parent
71e6d4cf88
commit
861a9648e8
3 changed files with 9 additions and 7 deletions
|
|
@ -51,7 +51,6 @@ impl ComponentTrait for Branding {
|
|||
|
||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||
let title = L10n::l("site_home").using(cx.langid());
|
||||
let slogan = self.slogan().using(cx.langid()).unwrap_or_default();
|
||||
PrepareMarkup::With(html! {
|
||||
div id=[self.id()] {
|
||||
div class="pt-branding__wrapper" {
|
||||
|
|
@ -64,7 +63,7 @@ impl ComponentTrait for Branding {
|
|||
(self.app_name())
|
||||
}
|
||||
}
|
||||
@if !slogan.is_empty() {
|
||||
@if let Some(slogan) = self.slogan().using(cx.langid()) {
|
||||
div class="pt-branding__slogan" {
|
||||
(slogan)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,11 +67,9 @@ impl ComponentTrait for Input {
|
|||
InputType::Url => "url",
|
||||
};
|
||||
let id = self.name().get().map(|name| concat_string!("edit-", name));
|
||||
let label = self.label().using(cx.langid()).unwrap_or_default();
|
||||
let description = self.help_text().using(cx.langid()).unwrap_or_default();
|
||||
PrepareMarkup::With(html! {
|
||||
div class=[self.classes().get()] {
|
||||
@if !label.is_empty() {
|
||||
@if let Some(label) = self.label().using(cx.langid()) {
|
||||
label class="form-label" for=[&id] {
|
||||
(label) " "
|
||||
@if self.required().get().is_some() {
|
||||
|
|
@ -96,7 +94,7 @@ impl ComponentTrait for Input {
|
|||
readonly=[self.readonly().get()]
|
||||
required=[self.required().get()]
|
||||
disabled=[self.disabled().get()] {}
|
||||
@if !description.is_empty() {
|
||||
@if let Some(description) = self.help_text().using(cx.langid()) {
|
||||
div class="form-text" { (description) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,8 +177,13 @@ pub struct L10n {
|
|||
|
||||
impl L10n {
|
||||
pub fn n(text: impl Into<String>) -> Self {
|
||||
let text = text.into();
|
||||
L10n {
|
||||
op: L10nOp::Text(text.into()),
|
||||
op: if text.trim().is_empty() {
|
||||
L10nOp::None
|
||||
} else {
|
||||
L10nOp::Text(text)
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue