summaryrefslogtreecommitdiffstats
path: root/vendor/icu_list/README.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/icu_list/README.md
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_list/README.md')
-rw-r--r--vendor/icu_list/README.md69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/icu_list/README.md b/vendor/icu_list/README.md
new file mode 100644
index 000000000..d17e8a8d7
--- /dev/null
+++ b/vendor/icu_list/README.md
@@ -0,0 +1,69 @@
+# icu_list [![crates.io](https://img.shields.io/crates/v/icu_list)](https://crates.io/crates/icu_list)
+
+Formatting lists in a locale-sensitive way.
+
+This module is published as its own crate ([`icu_list`](https://docs.rs/icu_list/latest/icu_list/))
+and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
+
+## Examples
+
+### Formatting *and* lists in Spanish
+
+```rust
+#
+let list_formatter = ListFormatter::try_new_and_with_length_unstable(
+ &icu_testdata::unstable(),
+ &locale!("es").into(),
+ ListLength::Wide,
+)
+.expect("Data should load successfully");
+
+assert_writeable_eq!(
+ list_formatter.format(["España", "Suiza"].iter()),
+ "España y Suiza",
+);
+
+// The Spanish 'y' sometimes becomes an 'e':
+assert_writeable_eq!(
+ list_formatter.format(["España", "Suiza", "Italia"].iter()),
+ "España, Suiza e Italia",
+);
+```
+
+### Formatting *or* lists in Thai
+
+```rust
+#
+let list_formatter = ListFormatter::try_new_or_with_length_unstable(
+ &icu_testdata::unstable(),
+ &locale!("th").into(),
+ ListLength::Short,
+)
+.expect("Data should load successfully");
+
+// We can use any Writeables as inputs
+assert_writeable_eq!(list_formatter.format(1..=3), "1, 2 หรือ 3",);
+```
+
+### Formatting unit lists in English
+
+```rust
+#
+let list_formatter = ListFormatter::try_new_unit_with_length_unstable(
+ &icu_testdata::unstable(),
+ &locale!("en").into(),
+ ListLength::Wide,
+)
+.expect("Data should load successfully");
+
+assert_writeable_eq!(
+ list_formatter.format(["1ft", "2in"].iter()),
+ "1ft, 2in",
+);
+```
+Note: this last example is not fully internationalized. See [icu4x/2192](https://github.com/unicode-org/icu4x/issues/2192)
+for full unit handling.
+
+## More Information
+
+For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).