🚧 New into_string() methods for L10n
This commit is contained in:
parent
689a22e51a
commit
e316e9aa91
3 changed files with 15 additions and 3 deletions
|
|
@ -142,7 +142,7 @@ fn about_pagetop() -> Container {
|
||||||
.with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALES_HOMEDEMO)))
|
.with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALES_HOMEDEMO)))
|
||||||
.with_component(Paragraph::with(
|
.with_component(Paragraph::with(
|
||||||
L10n::e("pagetop_text3", &LOCALES_HOMEDEMO)
|
L10n::e("pagetop_text3", &LOCALES_HOMEDEMO)
|
||||||
.with_arg("href", "https://docs.rs/pagetop/latest/pagetop".to_string()),
|
.with_arg("href", "https://docs.rs/pagetop/latest/pagetop"),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,8 @@ impl L10n {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_arg(&mut self, arg: &'static str, value: String) -> &mut Self {
|
pub fn alter_arg(&mut self, arg: &'static str, value: impl Into<String>) -> &mut Self {
|
||||||
self.args.insert(arg, value);
|
self.args.insert(arg, value.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,4 +115,8 @@ impl L10n {
|
||||||
pub fn args(&self) -> &HashMap<&str, String> {
|
pub fn args(&self) -> &HashMap<&str, String> {
|
||||||
&self.args
|
&self.args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_string(&self, cx: &mut Context) -> Option<String> {
|
||||||
|
self.prepare_component(cx).into_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,4 +39,12 @@ impl PrepareMarkup {
|
||||||
PrepareMarkup::With(markup) => markup,
|
PrepareMarkup::With(markup) => markup,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_string(self) -> Option<String> {
|
||||||
|
match self {
|
||||||
|
PrepareMarkup::None => None,
|
||||||
|
PrepareMarkup::Text(text) => Some(text.to_string()),
|
||||||
|
PrepareMarkup::With(markup) => Some(markup.into_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue