♻️ (examples): Extrae las traducciones propias

This commit is contained in:
Manuel Cillero 2026-04-30 06:27:58 +02:00
parent f359b36122
commit 0cf9cebe14
8 changed files with 100 additions and 105 deletions

View file

@ -1,5 +1,7 @@
use pagetop::prelude::*;
include_locales!(LOC from "examples/locale");
struct IntroColors;
impl Extension for IntroColors {
@ -14,59 +16,59 @@ async fn intro_colors(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
Intro::default()
.with_opening(IntroOpening::Custom)
.with_title(L10n::n("PageTop"))
.with_slogan(L10n::l("sample_colors_slogan"))
.with_slogan(L10n::t("colors_slogan", &LOC))
.with_button(None::<(L10n, FnPathByContext)>)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "1"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "1"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_1").using(cx)) }
p { (L10n::t("colors_val_1", &LOC).using(cx)) }
}
})),
)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "2"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "2"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_2").using(cx)) }
p { (L10n::t("colors_val_2", &LOC).using(cx)) }
}
})),
)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "3"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "3"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_3").using(cx)) }
p { (L10n::t("colors_val_3", &LOC).using(cx)) }
}
})),
)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "4"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "4"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_4").using(cx)) }
p { (L10n::t("colors_val_4", &LOC).using(cx)) }
}
})),
)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "5"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "5"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_5").using(cx)) }
p { (L10n::t("colors_val_5", &LOC).using(cx)) }
}
})),
)
.with_child(
Block::new()
.with_title(L10n::l("sample_colors_block").with_arg("n", "6"))
.with_title(L10n::t("colors_block", &LOC).with_arg("n", "6"))
.with_child(Html::with(|cx| {
html! {
p { (L10n::l("sample_colors_val_6").using(cx)) }
p { (L10n::t("colors_val_6", &LOC).using(cx)) }
}
})),
),

View file

@ -0,0 +1,8 @@
colors_slogan = Chromatic intro test
colors_block = Block { $n } — intro-bg-block-{ $n }
colors_val_1 = Background color: <code style="color: #8b2500">#FFB84B</code> — Amber gold.
colors_val_2 = Background color: <code style="color: #8b2500">#FFC66F</code> — Light golden.
colors_val_3 = Background color: <code style="color: #8b2500">#FFD493</code> — Pale golden.
colors_val_4 = Background color: <code style="color: #8b2500">#FFE3B7</code> — Light peach.
colors_val_5 = Background color: <code style="color: #8b2500">#FFF1DB</code> — Cream.
colors_val_6 = Background color: <code style="color: #8b2500">#FFFFFF</code> — White.

View file

@ -0,0 +1,23 @@
menus_item_label = Label
menus_item_link = Link
menus_item_blank = External link
menus_item_disabled = Disabled link
menus_test_title = Dropdown
menus_dev_header = Intro
menus_dev_getting_started = Getting started
menus_dev_guides = Development guides
menus_dev_forum = Developers forum
menus_sdk_header = Software Development Kits
menus_sdk_rust = SDKs Rust
menus_sdk_js = SDKs JavaScript
menus_sdk_python = SDKs Python
menus_plugin_header = Plugins
menus_plugin_auth = Rust Plugin Auth
menus_plugin_cache = Rust Plugin Cache
menus_item_sign_up = Sign up
menus_item_login = Login

View file

@ -0,0 +1,8 @@
colors_slogan = Prueba de intro cromática
colors_block = Bloque { $n } — intro-bg-block-{ $n }
colors_val_1 = Color de fondo: <code style="color: #8b2500">#FFB84B</code> — Ámbar dorado.
colors_val_2 = Color de fondo: <code style="color: #8b2500">#FFC66F</code> — Dorado claro.
colors_val_3 = Color de fondo: <code style="color: #8b2500">#FFD493</code> — Dorado pálido.
colors_val_4 = Color de fondo: <code style="color: #8b2500">#FFE3B7</code> — Melocotón claro.
colors_val_5 = Color de fondo: <code style="color: #8b2500">#FFF1DB</code> — Crema.
colors_val_6 = Color de fondo: <code style="color: #8b2500">#FFFFFF</code> — Blanco.

View file

@ -0,0 +1,23 @@
menus_item_label = Etiqueta
menus_item_link = Enlace
menus_item_blank = Enlace externo
menus_item_disabled = Enlace deshabilitado
menus_test_title = Desplegable
menus_dev_header = Introducción
menus_dev_getting_started = Primeros pasos
menus_dev_guides = Guías de desarrollo
menus_dev_forum = Foro de desarrolladores
menus_sdk_header = Kits de Desarrollo Software
menus_sdk_rust = SDKs de Rust
menus_sdk_js = SDKs de JavaScript
menus_sdk_python = SDKs de Python
menus_plugin_header = Plugins
menus_plugin_auth = Plugin Rust de autenticación
menus_plugin_cache = Plugin Rust de caché
menus_item_sign_up = Registrarse
menus_item_login = Iniciar sesión

View file

@ -2,6 +2,8 @@ use pagetop::prelude::*;
use pagetop_bootsier::prelude::*;
include_locales!(LOC from "examples/locale");
struct SuperMenu;
impl Extension for SuperMenu {
@ -14,63 +16,61 @@ impl Extension for SuperMenu {
.with_expand(BreakPoint::LG)
.with_item(navbar::Item::nav(
Nav::new()
.with_item(nav::Item::link(L10n::l("sample_menus_item_link"), |cx| {
.with_item(nav::Item::link(L10n::t("menus_item_link", &LOC), |cx| {
cx.route("/")
}))
.with_item(nav::Item::link_blank(
L10n::l("sample_menus_item_blank"),
L10n::t("menus_item_blank", &LOC),
|_| "https://docs.rs/pagetop".into(),
))
.with_item(nav::Item::dropdown(
Dropdown::new()
.with_title(L10n::l("sample_menus_test_title"))
.with_item(dropdown::Item::header(L10n::l("sample_menus_dev_header")))
.with_title(L10n::t("menus_test_title", &LOC))
.with_item(dropdown::Item::header(L10n::t("menus_dev_header", &LOC)))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_dev_getting_started"),
L10n::t("menus_dev_getting_started", &LOC),
|cx| cx.route("/dev/getting-started"),
))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_dev_guides"),
L10n::t("menus_dev_guides", &LOC),
|cx| cx.route("/dev/guides"),
))
.with_item(dropdown::Item::link_blank(
L10n::l("sample_menus_dev_forum"),
L10n::t("menus_dev_forum", &LOC),
|_| "https://forum.example.dev".into(),
))
.with_item(dropdown::Item::divider())
.with_item(dropdown::Item::header(L10n::l("sample_menus_sdk_header")))
.with_item(dropdown::Item::header(L10n::t("menus_sdk_header", &LOC)))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_sdk_rust"),
L10n::t("menus_sdk_rust", &LOC),
|cx| cx.route("/dev/sdks/rust"),
))
.with_item(dropdown::Item::link(L10n::l("sample_menus_sdk_js"), |cx| {
.with_item(dropdown::Item::link(L10n::t("menus_sdk_js", &LOC), |cx| {
cx.route("/dev/sdks/js")
}))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_sdk_python"),
L10n::t("menus_sdk_python", &LOC),
|cx| cx.route("/dev/sdks/python"),
))
.with_item(dropdown::Item::divider())
.with_item(dropdown::Item::header(L10n::l(
"sample_menus_plugin_header",
)))
.with_item(dropdown::Item::header(L10n::t("menus_plugin_header", &LOC)))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_plugin_auth"),
L10n::t("menus_plugin_auth", &LOC),
|cx| cx.route("/dev/sdks/rust/plugins/auth"),
))
.with_item(dropdown::Item::link(
L10n::l("sample_menus_plugin_cache"),
L10n::t("menus_plugin_cache", &LOC),
|cx| cx.route("/dev/sdks/rust/plugins/cache"),
))
.with_item(dropdown::Item::divider())
.with_item(dropdown::Item::label(L10n::l("sample_menus_item_label")))
.with_item(dropdown::Item::label(L10n::t("menus_item_label", &LOC)))
.with_item(dropdown::Item::link_disabled(
L10n::l("sample_menus_item_disabled"),
L10n::t("menus_item_disabled", &LOC),
|cx| cx.route("#"),
)),
))
.with_item(nav::Item::link_disabled(
L10n::l("sample_menus_item_disabled"),
L10n::t("menus_item_disabled", &LOC),
|cx| cx.route("#"),
)),
))
@ -80,11 +80,10 @@ impl Extension for SuperMenu {
ClassesOp::Add,
classes::Margin::with(Side::Start, ScaleSize::Auto).to_class(),
)
.with_item(nav::Item::link(
L10n::l("sample_menus_item_sign_up"),
|cx| cx.route("/auth/sign-up"),
))
.with_item(nav::Item::link(L10n::l("sample_menus_item_login"), |cx| {
.with_item(nav::Item::link(L10n::t("menus_item_sign_up", &LOC), |cx| {
cx.route("/auth/sign-up")
}))
.with_item(nav::Item::link(L10n::t("menus_item_login", &LOC), |cx| {
cx.route("/auth/login")
})),
));

View file

@ -1,34 +0,0 @@
# intro-colors.rs
sample_colors_slogan = Chromatic intro test
sample_colors_block = Block { $n } — intro-bg-block-{ $n }
sample_colors_val_1 = Background color: <code style="color: #8b2500">#FFB84B</code> — Amber gold.
sample_colors_val_2 = Background color: <code style="color: #8b2500">#FFC66F</code> — Light golden.
sample_colors_val_3 = Background color: <code style="color: #8b2500">#FFD493</code> — Pale golden.
sample_colors_val_4 = Background color: <code style="color: #8b2500">#FFE3B7</code> — Light peach.
sample_colors_val_5 = Background color: <code style="color: #8b2500">#FFF1DB</code> — Cream.
sample_colors_val_6 = Background color: <code style="color: #8b2500">#FFFFFF</code> — White.
# menus.rs
sample_menus_item_label = Label
sample_menus_item_link = Link
sample_menus_item_blank = External link
sample_menus_item_disabled = Disabled link
sample_menus_test_title = Dropdown
sample_menus_dev_header = Intro
sample_menus_dev_getting_started = Getting started
sample_menus_dev_guides = Development guides
sample_menus_dev_forum = Developers forum
sample_menus_sdk_header = Software Development Kits
sample_menus_sdk_rust = SDKs Rust
sample_menus_sdk_js = SDKs JavaScript
sample_menus_sdk_python = SDKs Python
sample_menus_plugin_header = Plugins
sample_menus_plugin_auth = Rust Plugin Auth
sample_menus_plugin_cache = Rust Plugin Cache
sample_menus_item_sign_up = Sign up
sample_menus_item_login = Login

View file

@ -1,34 +0,0 @@
# intro-colors.rs
sample_colors_slogan = Prueba de intro cromática
sample_colors_block = Bloque { $n } — intro-bg-block-{ $n }
sample_colors_val_1 = Color de fondo: <code style="color: #8b2500">#FFB84B</code> — Ámbar dorado.
sample_colors_val_2 = Color de fondo: <code style="color: #8b2500">#FFC66F</code> — Dorado claro.
sample_colors_val_3 = Color de fondo: <code style="color: #8b2500">#FFD493</code> — Dorado pálido.
sample_colors_val_4 = Color de fondo: <code style="color: #8b2500">#FFE3B7</code> — Melocotón claro.
sample_colors_val_5 = Color de fondo: <code style="color: #8b2500">#FFF1DB</code> — Crema.
sample_colors_val_6 = Color de fondo: <code style="color: #8b2500">#FFFFFF</code> — Blanco.
# menus.rs
sample_menus_item_label = Etiqueta
sample_menus_item_link = Enlace
sample_menus_item_blank = Enlace externo
sample_menus_item_disabled = Enlace deshabilitado
sample_menus_test_title = Desplegable
sample_menus_dev_header = Introducción
sample_menus_dev_getting_started = Primeros pasos
sample_menus_dev_guides = Guías de desarrollo
sample_menus_dev_forum = Foro de desarrolladores
sample_menus_sdk_header = Kits de Desarrollo Software
sample_menus_sdk_rust = SDKs de Rust
sample_menus_sdk_js = SDKs de JavaScript
sample_menus_sdk_python = SDKs de Python
sample_menus_plugin_header = Plugins
sample_menus_plugin_auth = Plugin Rust de autenticación
sample_menus_plugin_cache = Plugin Rust de caché
sample_menus_item_sign_up = Registrarse
sample_menus_item_login = Iniciar sesión