Name Description Size
algorithms.rs 18518
mod.rs Tools for locale fallback, enabling arbitrary input locales to be mapped into the nearest locale with data. The algorithm implemented in this module is called [Flexible Vertical Fallback]( https://docs.google.com/document/d/1Mp7EUyl-sFh_HZYgyeVwj88vJGpCBIWxzlCwGgLCDwM/edit). Watch [#2243](https://github.com/unicode-org/icu4x/issues/2243) to track improvements to this algorithm and steps to enshrine the algorithm in CLDR. # Examples ``` use icu_locid::locale; use icu_locid_transform::LocaleFallbacker; // Set up a LocaleFallbacker with data. let fallbacker = LocaleFallbacker::new(); // Create a LocaleFallbackerIterator with a default configuration. // By default, uses language priority with no additional extension keywords. let mut fallback_iterator = fallbacker .for_config(Default::default()) .fallback_for(locale!("hi-Latn-IN").into()); // Run the algorithm and check the results. assert_eq!(fallback_iterator.get(), &locale!("hi-Latn-IN").into()); fallback_iterator.step(); assert_eq!(fallback_iterator.get(), &locale!("hi-Latn").into()); fallback_iterator.step(); assert_eq!(fallback_iterator.get(), &locale!("en-IN").into()); fallback_iterator.step(); assert_eq!(fallback_iterator.get(), &locale!("en-001").into()); fallback_iterator.step(); assert_eq!(fallback_iterator.get(), &locale!("en").into()); fallback_iterator.step(); assert_eq!(fallback_iterator.get(), &locale!("und").into()); ``` 12136