sys-locale is supposed to return a valid BCP-47 language tag. Calling this on a US-based Ubuntu 20.04 LTS system returns "en_US". Note the underscore, not a dash.
Documentation for pub fn get_locale() -> Option<String> says it "returns Some(String) with a BCP-47 language tag inside."
The spec for BCP-47 is in RFC 5646, section 2.1, "Syntax".
"A language tag is composed from a sequence of one or more "subtags", each of which refines or narrows the range of language identified by the overall tag. Subtags, in turn, are a sequence of alphanumeric characters (letters and digits), distinguished and separated from other subtags in a tag by a hyphen ("-", [Unicode] U+002D)."
So RFC5646, BCP-47 requires a hyphen, not an underscore.
This breaks something that uses the tag.
OxiLangTag, a Rust library allowing to validate and normalize language tags following RFC 5646 (BCP 47), doesn't like the underscore:
The Unix/Linux LANG environment variable isn't BCP 47 compatible. It's close, but not the same. So, the Unix case in sys-locale needs to do some reformatting. Thanks.
sys-locale is supposed to return a valid BCP-47 language tag. Calling this on a US-based Ubuntu 20.04 LTS system returns "en_US". Note the underscore, not a dash.
Documentation for pub fn get_locale() -> Option<String> says it "returns Some(String) with a BCP-47 language tag inside."
The spec for BCP-47 is in RFC 5646, section 2.1, "Syntax".
"A language tag is composed from a sequence of one or more "subtags", each of which refines or narrows the range of language identified by the overall tag. Subtags, in turn, are a sequence of alphanumeric characters (letters and digits), distinguished and separated from other subtags in a tag by a hyphen ("-", [Unicode] U+002D)."
So RFC5646, BCP-47 requires a hyphen, not an underscore.
This breaks something that uses the tag. OxiLangTag, a Rust library allowing to validate and normalize language tags following RFC 5646 (BCP 47), doesn't like the underscore:
Err
value: LanguageTagParseError { kind: InvalidLanguage }'so there is software that fails because of this.
The Unix/Linux LANG environment variable isn't BCP 47 compatible. It's close, but not the same. So, the Unix case in sys-locale needs to do some reformatting. Thanks.