diff --git a/examples/intro-colors.rs b/examples/intro-colors.rs index 7853d41e..57ddeed4 100644 --- a/examples/intro-colors.rs +++ b/examples/intro-colors.rs @@ -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 { 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)) } } })), ), diff --git a/examples/locale/en-US/intro-colors.ftl b/examples/locale/en-US/intro-colors.ftl new file mode 100644 index 00000000..8b33f218 --- /dev/null +++ b/examples/locale/en-US/intro-colors.ftl @@ -0,0 +1,8 @@ +colors_slogan = Chromatic intro test +colors_block = Block { $n } — intro-bg-block-{ $n } +colors_val_1 = Background color: #FFB84B — Amber gold. +colors_val_2 = Background color: #FFC66F — Light golden. +colors_val_3 = Background color: #FFD493 — Pale golden. +colors_val_4 = Background color: #FFE3B7 — Light peach. +colors_val_5 = Background color: #FFF1DB — Cream. +colors_val_6 = Background color: #FFFFFF — White. diff --git a/examples/locale/en-US/navbar-menus.ftl b/examples/locale/en-US/navbar-menus.ftl new file mode 100644 index 00000000..98de2401 --- /dev/null +++ b/examples/locale/en-US/navbar-menus.ftl @@ -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 diff --git a/examples/locale/es-ES/intro-colors.ftl b/examples/locale/es-ES/intro-colors.ftl new file mode 100644 index 00000000..280ecb11 --- /dev/null +++ b/examples/locale/es-ES/intro-colors.ftl @@ -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: #FFB84B — Ámbar dorado. +colors_val_2 = Color de fondo: #FFC66F — Dorado claro. +colors_val_3 = Color de fondo: #FFD493 — Dorado pálido. +colors_val_4 = Color de fondo: #FFE3B7 — Melocotón claro. +colors_val_5 = Color de fondo: #FFF1DB — Crema. +colors_val_6 = Color de fondo: #FFFFFF — Blanco. diff --git a/examples/locale/es-ES/navbar-menus.ftl b/examples/locale/es-ES/navbar-menus.ftl new file mode 100644 index 00000000..af0b1ec3 --- /dev/null +++ b/examples/locale/es-ES/navbar-menus.ftl @@ -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 diff --git a/examples/navbar-menus.rs b/examples/navbar-menus.rs index 15065131..a0d85f3b 100644 --- a/examples/navbar-menus.rs +++ b/examples/navbar-menus.rs @@ -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") })), )); diff --git a/src/locale/en-US/sample.ftl b/src/locale/en-US/sample.ftl deleted file mode 100644 index 8bfa4cdf..00000000 --- a/src/locale/en-US/sample.ftl +++ /dev/null @@ -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: #FFB84B — Amber gold. -sample_colors_val_2 = Background color: #FFC66F — Light golden. -sample_colors_val_3 = Background color: #FFD493 — Pale golden. -sample_colors_val_4 = Background color: #FFE3B7 — Light peach. -sample_colors_val_5 = Background color: #FFF1DB — Cream. -sample_colors_val_6 = Background color: #FFFFFF — 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 diff --git a/src/locale/es-ES/sample.ftl b/src/locale/es-ES/sample.ftl deleted file mode 100644 index 5a706851..00000000 --- a/src/locale/es-ES/sample.ftl +++ /dev/null @@ -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: #FFB84B — Ámbar dorado. -sample_colors_val_2 = Color de fondo: #FFC66F — Dorado claro. -sample_colors_val_3 = Color de fondo: #FFD493 — Dorado pálido. -sample_colors_val_4 = Color de fondo: #FFE3B7 — Melocotón claro. -sample_colors_val_5 = Color de fondo: #FFF1DB — Crema. -sample_colors_val_6 = Color de fondo: #FFFFFF — 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