From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/unic-langid-impl/src/bin/generate_layout.rs | 130 ++ .../src/bin/generate_likelysubtags.rs | 202 ++ vendor/unic-langid-impl/src/errors.rs | 29 + vendor/unic-langid-impl/src/layout_table.rs | 4 + vendor/unic-langid-impl/src/lib.rs | 516 +++++ vendor/unic-langid-impl/src/likelysubtags/mod.rs | 136 ++ .../unic-langid-impl/src/likelysubtags/tables.rs | 2226 ++++++++++++++++++++ vendor/unic-langid-impl/src/parser/errors.rs | 20 + vendor/unic-langid-impl/src/parser/mod.rs | 83 + vendor/unic-langid-impl/src/serde.rs | 60 + vendor/unic-langid-impl/src/subtags/language.rs | 108 + vendor/unic-langid-impl/src/subtags/mod.rs | 9 + vendor/unic-langid-impl/src/subtags/region.rs | 74 + vendor/unic-langid-impl/src/subtags/script.rs | 62 + vendor/unic-langid-impl/src/subtags/variant.rs | 78 + 15 files changed, 3737 insertions(+) create mode 100644 vendor/unic-langid-impl/src/bin/generate_layout.rs create mode 100644 vendor/unic-langid-impl/src/bin/generate_likelysubtags.rs create mode 100644 vendor/unic-langid-impl/src/errors.rs create mode 100644 vendor/unic-langid-impl/src/layout_table.rs create mode 100644 vendor/unic-langid-impl/src/lib.rs create mode 100644 vendor/unic-langid-impl/src/likelysubtags/mod.rs create mode 100644 vendor/unic-langid-impl/src/likelysubtags/tables.rs create mode 100644 vendor/unic-langid-impl/src/parser/errors.rs create mode 100644 vendor/unic-langid-impl/src/parser/mod.rs create mode 100644 vendor/unic-langid-impl/src/serde.rs create mode 100644 vendor/unic-langid-impl/src/subtags/language.rs create mode 100644 vendor/unic-langid-impl/src/subtags/mod.rs create mode 100644 vendor/unic-langid-impl/src/subtags/region.rs create mode 100644 vendor/unic-langid-impl/src/subtags/script.rs create mode 100644 vendor/unic-langid-impl/src/subtags/variant.rs (limited to 'vendor/unic-langid-impl/src') diff --git a/vendor/unic-langid-impl/src/bin/generate_layout.rs b/vendor/unic-langid-impl/src/bin/generate_layout.rs new file mode 100644 index 000000000..35d8e27ae --- /dev/null +++ b/vendor/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