Skip to content

Commit cc55cec

Browse files
committed
added better i18n docs
1 parent 1e22fca commit cc55cec

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ These attributes can be applied to the struct itself.
116116
- **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
117117
for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
118118
- **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
119+
- **`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
119120

120121
### Field attributes
121122

@@ -133,6 +134,7 @@ These attributes can be applied to any field in the struct.
133134
- **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
134135
- **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
135136
- **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
137+
- **`i18n`** - Overrides the i18n key for the field. See [I18n](#i18n) for more information.
136138

137139
#### Formatting
138140

@@ -343,10 +345,12 @@ Please have a look at the [pagination example](https://github.com/Synphonyte/lep
343345
## I18n
344346

345347
To translate the column titles of the table using `leptos-i18n` you can enable the `"i18n"`
346-
feature. The field names of the struct are used as keys.
348+
feature. The field names of the struct are used as keys by default and can be customized using the `i18n` attribute.
347349

348350
Please have a look at the
349-
[i18n example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/i18n).
351+
[i18n example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/i18n)
352+
and at the sections [Struct attributes](#struct-attributes) and
353+
[Field attributes](#field-attributes) for more information.
350354

351355
## Contribution
352356

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
//! - **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
108108
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
109109
//! - **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
110+
//! - **`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
110111
//!
111112
//! ## Field attributes
112113
//!
@@ -124,6 +125,7 @@
124125
//! - **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
125126
//! - **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
126127
//! - **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
128+
//! - **`i18n`** - Overrides the i18n key for the field. See [I18n](#i18n) for more information.
127129
//!
128130
//! ### Formatting
129131
//!
@@ -376,10 +378,12 @@ pub struct TemperatureMeasurement {
376378
//! # I18n
377379
//!
378380
//! To translate the column titles of the table using `leptos-i18n` you can enable the `"i18n"`
379-
//! feature. The field names of the struct are used as keys.
381+
//! feature. The field names of the struct are used as keys by default and can be customized using the `i18n` attribute.
380382
//!
381383
//! Please have a look at the
382-
//! [i18n example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/i18n).
384+
//! [i18n example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/i18n)
385+
//! and at the sections [Struct attributes](#struct-attributes) and
386+
//! [Field attributes](#field-attributes) for more information.
383387
//!
384388
//! # Contribution
385389
//!

0 commit comments

Comments
 (0)