Files
herbapi/herbapi-ui/src/pages/home.rs
T
florian.berthold aa36c846d7 Add full DE/EN UI label translations across all pages
Add t() translation function to i18n.rs with ~200 key/value pairs
covering navigation, card headers, field labels, buttons, filters,
planting calendar rows, and general UI text in both German and English.

Updated all 11 source files to use t(&lang, "key") instead of
hardcoded English strings: app.rs (sidebar nav), all 7 page files
(species, cultivars, families, suppliers, home, search, sources),
and all 3 component files (planting_calendar, table_controls,
plant_card). Boolean values (Yes/No/Annual) are also translated.
2026-03-15 17:20:51 +01:00

62 lines
2.3 KiB
Rust

use dioxus::prelude::*;
use crate::api;
use crate::app::{Lang, Route};
use crate::components::plant_card::PlantCard;
use crate::i18n::{pick_name, t};
#[component]
pub fn Home() -> Element {
let lang = use_context::<Lang>().0;
let mut search_query = use_signal(|| String::new());
let species = use_resource(|| async { api::list_species(1, 12, None, None).await });
let l = lang.read().clone();
rsx! {
div { class: "page home-page",
h1 { "HerbAPI" }
p { class: "subtitle", "{t(&l, \"subtitle\")}" }
div { class: "search-bar",
input {
r#type: "text",
placeholder: "{t(&l, \"search.placeholder\")}",
value: "{search_query}",
oninput: move |e| search_query.set(e.value()),
onkeydown: move |e| {
if e.key() == Key::Enter {
let nav = navigator();
nav.push(Route::SearchPage {});
}
},
}
}
h2 { "{t(&l, \"page.recent_species\")}" }
match &*species.read() {
None => rsx! { p { "{t(&l, \"loading\")}" } },
Some(Err(e)) => rsx! { p { class: "error", "Error: {e}" } },
Some(Ok(data)) => rsx! {
div { class: "card-grid",
for s in data.data.iter().take(12) {
{
let card_common = pick_name(&lang.read(), &s.name_de, &s.name_en, &s.name_scientific);
let show_common = if card_common == s.name_scientific { None } else { Some(card_common) };
rsx! {
PlantCard {
key: "{s.id}",
slug: s.slug.clone(),
name: s.name_scientific.clone(),
name_common: show_common,
entity_type: "species".to_string(),
}
}
}
}
}
},
}
}
}
}