LCID-rs: A Rust library for Windows Language Code Identifiers

This library provides language code identifier parsing and information according to the MS-LCID "Windows Language Code Identifier (LCID) Reference".

toml [dependencies] lcid = "0.1"

It currently tracks the 14.1/2021-07-04 protocol revision. Future protocol revisions will may only trigger a minor version bump, so if you need a specific revision, pin this crate accordingly.

Language identifiers can be queried from a 32-bit unsigned integer (Language Code Identifier, or LCID) or a string (name, i.e. supported IETF BCP 47 language tag):

```rust use lcid::LanguageId; use std::convert::TryInto;

fn main() { let lcid = 1033; let lang: &LanguageId = lcid.tryinto().unwrap(); println!("LCID {} is '{}'/'{}'", lcid, lang.name, lang.englishname);

let name = "en-US";
let lang: &LanguageId = name.try_into().unwrap();
println!("Name '{}' is {}/'{}'", name, lang.lcid, lang.english_name);

} ```

prints

LCID 1033 is 'en-US'/'English (United States)' Name 'en-US' is 1033/'English (United States)'

How the information was generated

First, information was extracted from the MS-LCID PDF, and from both HTML tables of the associated LCIDs ("numbered") and the unassociated LCIDs ("named"). This was then manually cleaned, converted to JSON, and compared.

Then, the GetCultureInfo.ps1 script was run on a Windows Server 2019 machine (Build 17763) to gather further information from the System.Globalization.CultureInfo API. The values returned by the API do not always match the information in MS-LCID, so some fix-up were applied. For details, please see the script.

Finally, the lcid-gen crate generates code for the lcid crate (src/gen.rs). This is done to avoid having a build-time dependency on the JSON files.

MS-LCID errata

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.