Formatting lists in a locale-sensitive way.
This module is published as its own crate (icu_list
)
and as part of the icu
crate. See the latter for more details on the ICU4X project.
```rust # let listformatter = ListFormatter::trynewandwithlengthunstable( &icu_testdata::unstable(), &locale!("es").into(), ListLength::Wide, ) .expect("Data should load successfully");
assertwriteableeq!( list_formatter.format(["España", "Suiza"].iter()), "España y Suiza", );
// The Spanish 'y' sometimes becomes an 'e': assertwriteableeq!( list_formatter.format(["España", "Suiza", "Italia"].iter()), "España, Suiza e Italia", ); ```
```rust # let listformatter = ListFormatter::tryneworwithlengthunstable( &icu_testdata::unstable(), &locale!("th").into(), ListLength::Short, ) .expect("Data should load successfully");
// We can use any Writeables as inputs assertwriteableeq!(list_formatter.format(1..=3), "1, 2 หรือ 3",); ```
```rust # let listformatter = ListFormatter::trynewunitwithlengthunstable( &icu_testdata::unstable(), &locale!("en").into(), ListLength::Wide, ) .expect("Data should load successfully");
assertwriteableeq!( list_formatter.format(["1ft", "2in"].iter()), "1ft, 2in", ); ``` Note: this last example is not fully internationalized. See icu4x/2192 for full unit handling.
For more information on development, authorship, contributing etc. please visit ICU4X home page
.