🧑‍💻 Mejora y simplifica localización de módulos

This commit is contained in:
Manuel Cillero 2023-06-04 00:43:28 +02:00
parent d0add7c7ab
commit 520d3bb20b
21 changed files with 265 additions and 325 deletions

View file

@ -14,12 +14,12 @@ impl ModuleTrait for HomeDemo {
MODULE_DEMOHOME
}
fn name(&self) -> String {
_t("module_name", Locale::From(&LOCALE_DEMOHOME))
fn name(&self) -> L10n {
L10n::t("module_name", &LOCALE_DEMOHOME)
}
fn description(&self) -> Option<String> {
Some(_t("module_description", Locale::From(&LOCALE_DEMOHOME)))
fn description(&self) -> L10n {
L10n::t("module_description", &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(Text::t("page_title", &LOCALE_DEMOHOME))
.with_title(L10n::t("page_title", &LOCALE_DEMOHOME))
.with_context(ContextOp::AddStyleSheet(StyleSheet::located(
"/homedemo/css/styles.css",
)))
@ -55,11 +55,11 @@ fn hello_world() -> Container {
.with_classes(ClassesOp::Add, "hello-col-text")
.with_size(grid::ColumnSize::Is5of12)
.with_component(
Heading::h1(Text::t("page_title", &LOCALE_DEMOHOME))
Heading::h1(L10n::t("page_title", &LOCALE_DEMOHOME))
.with_display(HeadingDisplay::Medium),
)
.with_component(
Paragraph::with(Text::e("hello_intro", &LOCALE_DEMOHOME).with_arg(
Paragraph::with(L10n::e("hello_intro", &LOCALE_DEMOHOME).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
@ -69,7 +69,7 @@ fn hello_world() -> Container {
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(
Text::e("hello_powered", &LOCALE_DEMOHOME).with_arg(
L10n::e("hello_powered", &LOCALE_DEMOHOME).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
@ -80,14 +80,14 @@ fn hello_world() -> Container {
.with_component(
Anchor::button(
"https://github.com/manuelcillero/pagetop",
Text::t("hello_code", &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", Text::t("hello_welcome", &LOCALE_DEMOHOME))
Anchor::link("#welcome", L10n::t("hello_welcome", &LOCALE_DEMOHOME))
.with_left_icon(Icon::with("arrow-down-circle-fill"))
.with_classes(ClassesOp::Add, "welcome-link"),
),
@ -104,9 +104,9 @@ fn welcome() -> Container {
Container::section()
.with_id("welcome")
.with_classes(ClassesOp::Add, "welcome-col-text")
.with_component(Heading::h2(Text::t("welcome_page", &LOCALE_DEMOHOME)))
.with_component(Heading::h2(L10n::t("welcome_page", &LOCALE_DEMOHOME)))
.with_component(
Heading::h3(Text::e("welcome_subtitle", &LOCALE_DEMOHOME).with_arg(
Heading::h3(L10n::e("welcome_subtitle", &LOCALE_DEMOHOME).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
@ -116,10 +116,10 @@ fn welcome() -> Container {
.with_display(HeadingDisplay::Subtitle),
)
.with_component(
Paragraph::with(Text::t("welcome_text1", &LOCALE_DEMOHOME))
Paragraph::with(L10n::t("welcome_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(Text::t("welcome_text2", &LOCALE_DEMOHOME)))
.with_component(Paragraph::with(L10n::t("welcome_text2", &LOCALE_DEMOHOME)))
}
fn about_pagetop() -> Container {
@ -134,21 +134,15 @@ fn about_pagetop() -> Container {
.with_column(
grid::Column::new()
.with_classes(ClassesOp::Add, "pagetop-col-text")
.with_component(Heading::h2(Text::t("pagetop_title", &LOCALE_DEMOHOME)))
.with_component(Heading::h2(L10n::t("pagetop_title", &LOCALE_DEMOHOME)))
.with_component(
Paragraph::with(Text::t("pagetop_text1", &LOCALE_DEMOHOME))
Paragraph::with(L10n::t("pagetop_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(Text::t("pagetop_text2", &LOCALE_DEMOHOME)))
.with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALE_DEMOHOME)))
.with_component(Paragraph::with(
Text::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)),
),
),
L10n::e("pagetop_text3", &LOCALE_DEMOHOME)
.with_arg("href", "https://docs.rs/pagetop/latest/pagetop".to_string()),
)),
),
)
@ -160,12 +154,12 @@ fn promo_pagetop() -> Container {
.with_column(
grid::Column::new()
.with_classes(ClassesOp::Add, "promo-col-text")
.with_component(Heading::h2(Text::t(
.with_component(Heading::h2(L10n::t(
"pagetop_promo_title",
&LOCALE_DEMOHOME,
)))
.with_component(
Paragraph::with(Text::e("pagetop_promo_text1", &LOCALE_DEMOHOME).with_arg(
Paragraph::with(L10n::e("pagetop_promo_text1", &LOCALE_DEMOHOME).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
@ -196,15 +190,15 @@ fn reporting_issues() -> Container {
grid::Column::new()
.with_classes(ClassesOp::Add, "reporting-col-text")
.with_size(grid::ColumnSize::Is6of12)
.with_component(Heading::h2(Text::t(
.with_component(Heading::h2(L10n::t(
"report_problems_title",
&LOCALE_DEMOHOME,
)))
.with_component(
Paragraph::with(Text::t("report_problems_text1", &LOCALE_DEMOHOME))
Paragraph::with(L10n::t("report_problems_text1", &LOCALE_DEMOHOME))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(Text::t(
.with_component(Paragraph::with(L10n::t(
"report_problems_text2",
&LOCALE_DEMOHOME,
))),

View file

@ -16,8 +16,7 @@ welcome_text2 = If the problem persists, please contact your system administrato
pagetop_title = About PageTop
pagetop_text1 = If you can read this page, it means that the PageTop server is working properly, but has not yet been configured.
pagetop_text2 = PageTop defines an interface for the most stable and popular Rust packages to build modular, extensible and configurable web solutions.
pagetop_text3 = For more information on PageTop please visit the { $pagetop_website }.
pagetop_website = technical documentation
pagetop_text3 = For more information on PageTop please visit the <a href="{ $href }" target="_blank">technical documentation</a>.
pagetop_promo_title = Promoting PageTop
pagetop_promo_text1 = You are free to use the image below on applications powered by { $pagetop }. Thanks for using PageTop!

View file

@ -16,8 +16,7 @@ welcome_text2 = Si el problema persiste, póngase en contacto con el administrad
pagetop_title = Sobre PageTop
pagetop_text1 = Si puedes leer esta página, significa que el servidor PageTop funciona correctamente, pero aún no se ha configurado.
pagetop_text2 = PageTop define una interfaz para los paquetes Rust más estables y populares para crear soluciones web modulares, extensibles y configurables.
pagetop_text3 = Para más información sobre PageTop, por favor visita la { $pagetop_website }.
pagetop_website = documentación técnica
pagetop_text3 = Para más información sobre PageTop, por favor visita la <a href="{ $href }" target="_blank">documentación técnica</a>.
pagetop_promo_title = Promociona PageTop
pagetop_promo_text1 = Eres libre de usar la siguiente imagen en aplicaciones desarrolladas con { $pagetop }. ¡Gracias por usar PageTop!