🍻 Tercera revista a las traducciones por contexto

This commit is contained in:
Manuel Cillero 2023-05-27 22:44:12 +02:00
parent 88d6ce2a72
commit dd443ca375
21 changed files with 415 additions and 252 deletions

View file

@ -15,11 +15,11 @@ impl ModuleTrait for HomeDemo {
}
fn name(&self) -> String {
_t("module_name", Locale::From(&LOCALE_DEMOHOME))
t("module_name", Locale::From(&LOCALE_DEMOHOME))
}
fn description(&self) -> Option<String> {
Some(_t("module_description", Locale::From(&LOCALE_DEMOHOME)))
Some(t("module_description", Locale::From(&LOCALE_DEMOHOME)))
}
fn dependencies(&self) -> Vec<ModuleStaticRef> {
@ -34,7 +34,7 @@ impl ModuleTrait for HomeDemo {
async fn demo(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
Page::new(request)
.with_title(_t("page_title", Locale::From(&LOCALE_DEMOHOME)).as_str())
.with_title(L10n::t("page_title", &LOCALE_DEMOHOME))
.with_context(ContextOp::AddStyleSheet(StyleSheet::located(
"/homedemo/css/styles.css",
)))
@ -55,47 +55,41 @@ fn hello_world() -> Container {
.with_classes(ClassesOp::Add, "hello-col-text")
.with_size(grid::ColumnSize::Is5of12)
.with_component(
Heading::h1(html! {
(_t("page_title", Locale::From(&LOCALE_DEMOHOME)))
})
.with_display(HeadingDisplay::Medium),
Heading::h1(L10n::t("page_title", &LOCALE_DEMOHOME))
.with_display(HeadingDisplay::Medium),
)
.with_component(
Paragraph::with(html! {
(_e("hello_intro", Locale::With(&LOCALE_DEMOHOME, &args![
"app" => format!(
"<span class=\"app-name\">{}</span>",
&config::SETTINGS.app.name,
)
])))
})
Paragraph::with(L10n::e("hello_intro", &LOCALE_DEMOHOME).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
&config::SETTINGS.app.name,
),
))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(html! {
(_e("hello_powered", Locale::With(&LOCALE_DEMOHOME, &args![
"pagetop" => format!(
.with_component(Paragraph::with(
L10n::e("hello_powered", &LOCALE_DEMOHOME).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"https://pagetop.cillero.es",
"PageTop",
)
])))
}))
"https://pagetop.cillero.es", "PageTop",
),
),
))
.with_component(
Anchor::button(
"https://github.com/manuelcillero/pagetop",
html! { (_t("hello_code", Locale::From(&LOCALE_DEMOHOME))) },
L10n::t("hello_code", &LOCALE_DEMOHOME),
)
.with_target(AnchorTarget::Blank)
.with_left_icon(Icon::with("git"))
.with_classes(ClassesOp::Add, "code-link"),
)
.with_component(
Anchor::link(
"#welcome",
html! { (_t("hello_welcome", Locale::From(&LOCALE_DEMOHOME))) },
)
.with_left_icon(Icon::with("arrow-down-circle-fill"))
.with_classes(ClassesOp::Add, "welcome-link"),
Anchor::link("#welcome", L10n::t("hello_welcome", &LOCALE_DEMOHOME))
.with_left_icon(Icon::with("arrow-down-circle-fill"))
.with_classes(ClassesOp::Add, "welcome-link"),
),
)
.with_column(
@ -110,29 +104,22 @@ fn welcome() -> Container {
Container::section()
.with_id("welcome")
.with_classes(ClassesOp::Add, "welcome-col-text")
.with_component(Heading::h2(html! {
(_t("welcome_page", Locale::From(&LOCALE_DEMOHOME)))
}))
.with_component(Heading::h2(L10n::t("welcome_page", &LOCALE_DEMOHOME)))
.with_component(
Heading::h3(html! {
(_e("welcome_subtitle", Locale::With(&LOCALE_DEMOHOME, &args![
"app" => format!(
"<span class=\"app-name\">{}</span>",
&config::SETTINGS.app.name
)
])))
})
Heading::h3(L10n::e("welcome_subtitle", &LOCALE_DEMOHOME).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
&config::SETTINGS.app.name
),
))
.with_display(HeadingDisplay::Subtitle),
)
.with_component(
Paragraph::with(html! {
(_t("welcome_text1", Locale::From(&LOCALE_DEMOHOME)))
})
.with_display(ParagraphDisplay::Small),
Paragraph::with(L10n::t("welcome_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(
html! { (_t("welcome_text2", Locale::From(&LOCALE_DEMOHOME))) },
))
.with_component(Paragraph::with(L10n::t("welcome_text2", &LOCALE_DEMOHOME)))
}
fn about_pagetop() -> Container {
@ -147,27 +134,22 @@ fn about_pagetop() -> Container {
.with_column(
grid::Column::new()
.with_classes(ClassesOp::Add, "pagetop-col-text")
.with_component(Heading::h2(html! {
(_t("pagetop_title", Locale::From(&LOCALE_DEMOHOME)))
}))
.with_component(Heading::h2(L10n::t("pagetop_title", &LOCALE_DEMOHOME)))
.with_component(
Paragraph::with(html! {
(_t("pagetop_text1", Locale::From(&LOCALE_DEMOHOME)))
})
.with_display(ParagraphDisplay::Small),
Paragraph::with(L10n::t("pagetop_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(html! {
(_t("pagetop_text2", Locale::From(&LOCALE_DEMOHOME)))
}))
.with_component(Paragraph::with(html! {
(_e("pagetop_text3", Locale::With(&LOCALE_DEMOHOME, &args![
"pagetop_website" => format!(
.with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALE_DEMOHOME)))
.with_component(Paragraph::with(
L10n::e("pagetop_text3", &LOCALE_DEMOHOME).with_arg(
"pagetop_website",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"https://docs.rs/pagetop/latest/pagetop",
_t("pagetop_website", Locale::From(&LOCALE_DEMOHOME)),
)
])))
})),
t("pagetop_website", Locale::From(&LOCALE_DEMOHOME)),
),
),
)),
),
)
}
@ -178,19 +160,18 @@ fn promo_pagetop() -> Container {
.with_column(
grid::Column::new()
.with_classes(ClassesOp::Add, "promo-col-text")
.with_component(Heading::h2(html! {
(_t("pagetop_promo_title", Locale::From(&LOCALE_DEMOHOME)))
}))
.with_component(Heading::h2(L10n::t(
"pagetop_promo_title",
&LOCALE_DEMOHOME,
)))
.with_component(
Paragraph::with(html! {
(_e("pagetop_promo_text1", Locale::With(&LOCALE_DEMOHOME, &args![
"pagetop" => format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"https://crates.io/crates/pagetop",
"PageTop",
)
])))
})
Paragraph::with(L10n::e("pagetop_promo_text1", &LOCALE_DEMOHOME).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"https://crates.io/crates/pagetop", "PageTop",
),
))
.with_display(ParagraphDisplay::Small),
),
)
@ -215,18 +196,18 @@ fn reporting_issues() -> Container {
grid::Column::new()
.with_classes(ClassesOp::Add, "reporting-col-text")
.with_size(grid::ColumnSize::Is6of12)
.with_component(Heading::h2(html! {
(_t("report_problems_title", Locale::From(&LOCALE_DEMOHOME)))
}))
.with_component(Heading::h2(L10n::t(
"report_problems_title",
&LOCALE_DEMOHOME,
)))
.with_component(
Paragraph::with(html! {
(_t("report_problems_text1", Locale::From(&LOCALE_DEMOHOME)))
})
.with_display(ParagraphDisplay::Small),
Paragraph::with(L10n::t("report_problems_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(html! {
(_t("report_problems_text2", Locale::From(&LOCALE_DEMOHOME)))
})),
.with_component(Paragraph::with(L10n::t(
"report_problems_text2",
&LOCALE_DEMOHOME,
))),
),
)
}