1- leptos_i18n:: load_locales!( ) ;
21use :: chrono:: NaiveDate ;
32use :: time:: Date ;
43use :: uuid:: Uuid ;
54use i18n:: * ;
65use leptos:: * ;
76use 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) ]
1213pub 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