Add DE/EN language toggle with bilingual descriptions
- Language switcher in sidebar (DE/EN buttons, persists to localStorage) - i18n module with pick_desc/pick_name helpers for language-aware fallback - All detail/list pages use language context for names and descriptions - Species/Cultivar types updated with description_de/description_en - Common Name column added to species/families lists
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::api;
|
||||
use crate::app::Route;
|
||||
use crate::app::{Lang, Route};
|
||||
use crate::components::plant_card::PlantCard;
|
||||
use crate::i18n::pick_name;
|
||||
|
||||
#[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 });
|
||||
|
||||
@@ -36,12 +38,18 @@ pub fn Home() -> Element {
|
||||
Some(Ok(data)) => rsx! {
|
||||
div { class: "card-grid",
|
||||
for s in data.data.iter().take(12) {
|
||||
PlantCard {
|
||||
key: "{s.id}",
|
||||
slug: s.slug.clone(),
|
||||
name: s.name_scientific.clone(),
|
||||
name_common: s.name_en.clone(),
|
||||
entity_type: "species".to_string(),
|
||||
{
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user