canonicalizer.rs |
The collection of code for locale canonicalization. |
23451 |
directionality.rs |
|
9484 |
exemplar_chars.rs |
This module provides APIs for getting exemplar characters for a locale.
Exemplars are characters used by a language, separated into different sets.
The sets are: main, auxiliary, punctuation, numbers, and index.
The sets define, according to typical usage in the language,
which characters occur in which contexts with which frequency.
For more information, see the documentation in the
[Exemplars section in Unicode Technical Standard #35](https://unicode.org/reports/tr35/tr35-general.html#Exemplars)
of the LDML specification.
# Examples
```
use icu::locale::exemplar_chars::ExemplarCharacters;
use icu::locale::locale;
let locale = locale!("en-001").into();
let exemplars_main = ExemplarCharacters::try_new_main(&locale)
.expect("locale should be present");
assert!(exemplars_main.contains('a'));
assert!(exemplars_main.contains('z'));
assert!(exemplars_main.contains_str("a"));
assert!(!exemplars_main.contains_str("ä"));
assert!(!exemplars_main.contains_str("ng"));
``` |
10649 |
expander.rs |
|
21107 |
fallback |
|
|
lib.rs |
Canonicalization of locale identifiers based on [`CLDR`] data.
This module is published as its own crate ([`icu_locale`](https://docs.rs/icu_locale/latest/icu_locale/))
and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project.
It currently supports locale canonicalization based upon the canonicalization
algorithm from [`UTS #35: Unicode LDML 3. LocaleId Canonicalization`],
as well as the minimize and maximize likely subtags algorithms
as described in [`UTS #35: Unicode LDML 3. Likely Subtags`].
The maximize method potentially updates a passed in locale in place
depending up the results of running the 'Add Likely Subtags' algorithm
from [`UTS #35: Unicode LDML 3. Likely Subtags`].
This minimize method returns a new Locale that is the result of running the
'Remove Likely Subtags' algorithm from [`UTS #35: Unicode LDML 3. Likely Subtags`].
# Examples
```
use icu::locale::Locale;
use icu::locale::{LocaleCanonicalizer, TransformResult};
let lc = LocaleCanonicalizer::new_extended();
let mut locale: Locale = "ja-Latn-fonipa-hepburn-heploc"
.parse()
.expect("parse failed");
assert_eq!(lc.canonicalize(&mut locale), TransformResult::Modified);
assert_eq!(locale, "ja-Latn-alalc97-fonipa".parse::<Locale>().unwrap());
```
```
use icu::locale::{locale, LocaleExpander, TransformResult};
let lc = LocaleExpander::new_common();
let mut locale = locale!("zh-CN");
assert_eq!(lc.maximize(&mut locale.id), TransformResult::Modified);
assert_eq!(locale, locale!("zh-Hans-CN"));
let mut locale = locale!("zh-Hant-TW");
assert_eq!(lc.maximize(&mut locale.id), TransformResult::Unmodified);
assert_eq!(locale, locale!("zh-Hant-TW"));
```
```
use icu::locale::{locale, LocaleExpander, TransformResult};
use writeable::assert_writeable_eq;
let lc = LocaleExpander::new_common();
let mut locale = locale!("zh-Hans-CN");
assert_eq!(lc.minimize(&mut locale.id), TransformResult::Modified);
assert_eq!(locale, locale!("zh"));
let mut locale = locale!("zh");
assert_eq!(lc.minimize(&mut locale.id), TransformResult::Unmodified);
assert_eq!(locale, locale!("zh"));
```
[`ICU4X`]: ../icu/index.html
[`CLDR`]: http://cldr.unicode.org/
[`UTS #35: Unicode LDML 3. Likely Subtags`]: https://www.unicode.org/reports/tr35/#Likely_Subtags.
[`UTS #35: Unicode LDML 3. LocaleId Canonicalization`]: http://unicode.org/reports/tr35/#LocaleId_Canonicalization, |
4088 |
provider.rs |
🚧 \[Unstable\] Data provider struct definitions for this ICU4X component.
<div class="stab unstable">
🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
including in SemVer minor releases. While the serde representation of data structs is guaranteed
to be stable, their Rust representation might not be. Use with caution.
</div>
Read more about data providers: [`icu_provider`] |
20252 |