Añade tipos para renderizar atributos HTML

This commit is contained in:
Manuel Cillero 2025-07-21 20:52:45 +02:00
parent 613ab5243c
commit f88513d67f
7 changed files with 393 additions and 2 deletions

View file

@ -284,7 +284,7 @@ include_locales!(LOCALES_PAGETOP);
// * `None` - No se aplica ninguna localización.
// * `Text` - Con una cadena literal que se devolverá tal cual.
// * `Translate` - Con la clave a resolver en el `Locales` indicado.
#[derive(AutoDefault)]
#[derive(AutoDefault, Clone, Debug)]
enum L10nOp {
#[default]
None,
@ -322,7 +322,7 @@ enum L10nOp {
/// // Traducción con clave, conjunto de traducciones e identificador de idioma a usar.
/// let bye = L10n::t("goodbye", &LOCALES_CUSTOM).using(LangMatch::langid_or_default("it"));
/// ```
#[derive(AutoDefault)]
#[derive(AutoDefault, Clone)]
pub struct L10n {
op: L10nOp,
#[default(&LOCALES_PAGETOP)]
@ -411,6 +411,17 @@ impl L10n {
}
}
impl fmt::Debug for L10n {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("L10n")
.field("op", &self.op)
.field("args", &self.args)
// No se puede mostrar `locales`. Se representa con un texto fijo.
.field("locales", &"<StaticLoader>")
.finish()
}
}
impl fmt::Display for L10n {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let content = match &self.op {