From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../unic-langid-impl/src/bin/generate_layout.rs | 130 ++ .../src/bin/generate_likelysubtags.rs | 201 ++ third_party/rust/unic-langid-impl/src/errors.rs | 29 + .../rust/unic-langid-impl/src/layout_table.rs | 4 + third_party/rust/unic-langid-impl/src/lib.rs | 516 +++++ .../rust/unic-langid-impl/src/likelysubtags/mod.rs | 136 ++ .../unic-langid-impl/src/likelysubtags/tables.rs | 2226 ++++++++++++++++++++ .../rust/unic-langid-impl/src/parser/errors.rs | 20 + .../rust/unic-langid-impl/src/parser/mod.rs | 83 + third_party/rust/unic-langid-impl/src/serde.rs | 60 + .../rust/unic-langid-impl/src/subtags/language.rs | 108 + .../rust/unic-langid-impl/src/subtags/mod.rs | 9 + .../rust/unic-langid-impl/src/subtags/region.rs | 74 + .../rust/unic-langid-impl/src/subtags/script.rs | 62 + .../rust/unic-langid-impl/src/subtags/variant.rs | 78 + 15 files changed, 3736 insertions(+) create mode 100644 third_party/rust/unic-langid-impl/src/bin/generate_layout.rs create mode 100644 third_party/rust/unic-langid-impl/src/bin/generate_likelysubtags.rs create mode 100644 third_party/rust/unic-langid-impl/src/errors.rs create mode 100644 third_party/rust/unic-langid-impl/src/layout_table.rs create mode 100644 third_party/rust/unic-langid-impl/src/lib.rs create mode 100644 third_party/rust/unic-langid-impl/src/likelysubtags/mod.rs create mode 100644 third_party/rust/unic-langid-impl/src/likelysubtags/tables.rs create mode 100644 third_party/rust/unic-langid-impl/src/parser/errors.rs create mode 100644 third_party/rust/unic-langid-impl/src/parser/mod.rs create mode 100644 third_party/rust/unic-langid-impl/src/serde.rs create mode 100644 third_party/rust/unic-langid-impl/src/subtags/language.rs create mode 100644 third_party/rust/unic-langid-impl/src/subtags/mod.rs create mode 100644 third_party/rust/unic-langid-impl/src/subtags/region.rs create mode 100644 third_party/rust/unic-langid-impl/src/subtags/script.rs create mode 100644 third_party/rust/unic-langid-impl/src/subtags/variant.rs (limited to 'third_party/rust/unic-langid-impl/src') diff --git a/third_party/rust/unic-langid-impl/src/bin/generate_layout.rs b/third_party/rust/unic-langid-impl/src/bin/generate_layout.rs new file mode 100644 index 0000000000..35d8e27aed --- /dev/null +++ b/third_party/rust/unic-langid-impl/src/bin/generate_layout.rs @@ -0,0 +1,130 @@ +use serde_json::Value; +use std::collections::HashMap; +use std::collections::HashSet; +use std::fs; +use unic_langid_impl::subtags::{Language, Script}; +use unic_langid_impl::CharacterDirection; +use unic_langid_impl::LanguageIdentifier; + +fn langid_to_direction_map(path: &str) -> HashMap { + let mut result = HashMap::new(); + for entry in fs::read_dir(path).unwrap() { + let entry = entry.unwrap(); + let mut path = entry.path(); + path.push("layout.json"); + let contents = fs::read_to_string(path).expect("Something went wrong reading the file"); + let v: Value = serde_json::from_str(&contents).unwrap(); + + let langid_key = v["main"].as_object().unwrap().keys().nth(0).unwrap(); + + if langid_key == "root" { + continue; + } + let langid: LanguageIdentifier = langid_key.parse().unwrap(); + + let character_order = match v["main"][langid_key]["layout"]["orientation"]["characterOrder"] + .as_str() + .unwrap() + { + "right-to-left" => CharacterDirection::RTL, + "left-to-right" => CharacterDirection::LTR, + _ => unimplemented!("Encountered unknown directionality!"), + }; + result.insert(langid, character_order); + } + result +} + +fn check_all_variants_rtl( + map: &HashMap, + lang: Option, + script: Option