Skip to content

Commit 72951d8

Browse files
updated example
1 parent 59b726f commit 72951d8

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

examples/i18n/locales/de.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"id": "ID",
32
"title": "Titel",
43
"author": "Autor",
54
"publish_date": "Veröffentlichungsdatum",
65
"read_date": "Lesedatum",
76
"description": "Beschreibung",
87
"click_to_change_lang": "Klicken um Sprache zu ändern"
9-
}
8+
}

examples/i18n/locales/en.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"id": "ID",
32
"title": "Title",
43
"author": "Author",
54
"publish_date": "Publish Date",
65
"read_date": "Read Date",
76
"description": "Description",
87
"click_to_change_lang": "Click to change language"
9-
}
8+
}

examples/i18n/src/main.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
leptos_i18n::load_locales!();
21
use ::chrono::NaiveDate;
32
use ::time::Date;
43
use ::uuid::Uuid;
54
use i18n::*;
65
use leptos::*;
76
use leptos_struct_table::*;
87

8+
leptos_i18n::load_locales!();
9+
910
/// This generates the component BookTable
1011
#[derive(TableRow, Clone)]
1112
#[table(sortable, impl_vec_data_provider)]
1213
pub struct Book {
1314
/// Id of the entry.
15+
#[table(i18n(skip))]
1416
pub id: Uuid,
1517
/// Title of the book.
1618
pub title: String,
@@ -21,8 +23,8 @@ pub struct Book {
2123
/// Date when book was read
2224
pub read_date: Option<Date>,
2325
/// Description of the book. Optional.
24-
#[table(none_value = "-")]
25-
pub description: Option<String>,
26+
#[table(none_value = "-", i18n(key = description))]
27+
pub desc: Option<String>,
2628
/// Example on hidden member.
2729
#[table(skip)]
2830
pub hidden_field: String,
@@ -40,7 +42,7 @@ fn main() {
4042
author: "F. Scott Fitzgerald".to_string(),
4143
publish_date: Some(NaiveDate::from_ymd_opt(1925, 4, 10).unwrap()),
4244
read_date: Some(Date::from_calendar_date(2024, ::time::Month::January, 2).unwrap()),
43-
description: Some(
45+
desc: Some(
4446
"A story of wealth, love, and the American Dream in the 1920s.".to_string(),
4547
),
4648
hidden_field: "hidden".to_string(),
@@ -51,7 +53,7 @@ fn main() {
5153
author: "John Steinbeck".to_string(),
5254
publish_date: Some(NaiveDate::from_ymd_opt(1939, 4, 14).unwrap()),
5355
read_date: None,
54-
description: None,
56+
desc: None,
5557
hidden_field: "not visible in the table".to_string(),
5658
},
5759
Book {
@@ -60,7 +62,7 @@ fn main() {
6062
author: "George Orwell".to_string(),
6163
publish_date: Some(NaiveDate::from_ymd_opt(1949, 6, 8).unwrap()),
6264
read_date: None,
63-
description: None,
65+
desc: None,
6466
hidden_field: "hidden".to_string(),
6567
},
6668
Book {
@@ -69,7 +71,7 @@ fn main() {
6971
author: "James Joyce".to_string(),
7072
publish_date: Some(NaiveDate::from_ymd_opt(1922, 2, 2).unwrap()),
7173
read_date: None,
72-
description: None,
74+
desc: None,
7375
hidden_field: "hidden".to_string(),
7476
},
7577
];

0 commit comments

Comments
 (0)