Module extensions
Unicode Extensions provide a mechanism to extend the LanguageIdentifier with
additional bits of information - a combination of a LanguageIdentifier and Extensions
is called Locale.
There are four types of extensions:
Unicode Extensions- marked asu.Transform Extensions- marked ast.Private Use Extensions- marked asx.Other Extensions- marked as anya-zexcept ofu,tandx.
One can think of extensions as a bag of extra information on top of basic 4 subtags.
Notice: Other extension type is currently not supported.
Examples
use ;
use Locale;
let loc: Locale = "en-US-u-ca-buddhist-t-en-us-h0-hybrid-x-foo"
.parse
.expect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
let key: Key = "ca".parse.expect;
let value: Value = "buddhist".parse.expect;
assert_eq!;
Syntactic vs Semantic Extension Handling
This module is useful when you need to work with Locale extensions at a syntactic level,
perhaps for parsing or generating locale identifiers that include any syntactically valid
extensions.
For handling and validating known CLDR values with semantic meaning, see the
crate::preferences::extensions module.
Modules
- other Other Use Extensions is a list of extensions other than unicode, transform or private.
- private Private Use Extensions is a list of extensions intended for private use.
- transform Transform Extensions provide information on content transformations in a given locale.
- unicode Unicode Extensions provide information about user preferences in a given locale.
Structs
-
Extensions
A map of extensions associated with a given
Locale.
Enums
- ExtensionType Defines the type of extension.