Expand description
§use-locale-tag
Small BCP 47 / Unicode-style locale tag parsing and normalization primitives for RustUse.
§Example
use use_locale_tag::{normalize_locale_tag, parse_locale_tag};
let tag = parse_locale_tag("zh-hant-tw").unwrap();
assert_eq!(tag.as_str(), "zh-Hant-TW");
assert_eq!(normalize_locale_tag("en-us"), Some("en-US".to_string()));§Scope
- Parse locale tags with language, optional script, optional region, and supported suffixes.
- Normalize language subtags to lowercase.
- Normalize script subtags to title case.
- Normalize alphabetic region subtags to uppercase.
- Preserve supported variants, extensions, and private-use suffixes without database canonicalization.
§Non-goals
- Full CLDR canonicalization.
- ICU replacement behavior.
- Translation catalogs.
- Message formatting.
- Locale data loading.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Locale
Tag - A normalized locale tag.
- Locale
TagParts - Parsed locale tag components.
Functions§
- is_
locale_ tag - Returns
truewhen the input is a supported locale tag shape. - normalize_
locale_ tag - Normalizes a locale tag when it is syntactically valid for this crate’s subset.
- parse_
locale_ tag - Parses a locale tag and normalizes its core language, script, and region subtags.
- parse_
locale_ tag_ parts - Parses a locale tag into normalized parts.