Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Units Data from CLDR #4660

Merged
merged 23 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c01e957
Move provider.rs for to provider/currency.rs
younies Mar 6, 2024
61ffd2f
fix the data
younies Mar 6, 2024
b362e25
move percent data to `percent.rs`
younies Mar 7, 2024
1425d95
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 7, 2024
2dc2e99
download cldr units data
younies Mar 7, 2024
b4bd8af
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 17, 2024
8f77374
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 17, 2024
2d31336
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 19, 2024
7933ffb
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 19, 2024
c7df854
build data model
younies Mar 20, 2024
d98f0a2
create the datagen `units/data.rs` file
younies Mar 20, 2024
605df04
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies Mar 28, 2024
4955b6c
fix merge
younies Mar 28, 2024
6c68f65
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies May 16, 2024
2df79b6
fix fmt
younies May 16, 2024
c4702de
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies May 28, 2024
6165432
Merge branch 'main' into impl-units-short-narrow-data
younies May 28, 2024
1a81af9
Merge branch 'main' of github.com:unicode-org/icu4x into impl-units-s…
younies May 28, 2024
7dbb124
fix clippy
younies May 28, 2024
2c4aa63
remove unused file
younies May 28, 2024
9660b6a
Merge branch 'main' into impl-units-short-narrow-data
younies May 28, 2024
4308bfa
update the data
younies May 28, 2024
fcf1e23
Merge branch 'impl-units-short-narrow-data' of github.com:younies/icu…
younies May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions components/experimental/src/dimension/provider/units.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

// Provider structs must be stable
#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)]

//! Data provider struct definitions for this ICU4X component.
//!
//! Read more about data providers: [`icu_provider`]


use alloc::borrow::Cow;
use icu_provider::prelude::*;
use tinystr::UnvalidatedTinyAsciiStr;
use zerovec::{VarZeroVec, ZeroMap};


18 changes: 18 additions & 0 deletions provider/datagen/src/provider/tests/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,24 @@ impl DatagenProvider {
("cldr-numbers-full/main/th/numbers.json", include_bytes!("../../../tests/data/cldr/cldr-numbers-full/main/th/numbers.json").as_slice()),
("cldr-numbers-full/main/tr/numbers.json", include_bytes!("../../../tests/data/cldr/cldr-numbers-full/main/tr/numbers.json").as_slice()),
("cldr-numbers-full/main/und/numbers.json", include_bytes!("../../../tests/data/cldr/cldr-numbers-full/main/und/numbers.json").as_slice()),
("cldr-units-full/main/ar/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/ar/units.json").as_slice()),
("cldr-units-full/main/ar-EG/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/ar-EG/units.json").as_slice()),
("cldr-units-full/main/bn/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/bn/units.json").as_slice()),
("cldr-units-full/main/ccp/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/ccp/units.json").as_slice()),
("cldr-units-full/main/en/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/en/units.json").as_slice()),
("cldr-units-full/main/en-001/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/en-001/units.json").as_slice()),
("cldr-units-full/main/en-ZA/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/en-ZA/units.json").as_slice()),
("cldr-units-full/main/es/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/es/units.json").as_slice()),
("cldr-units-full/main/es-AR/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/es-AR/units.json").as_slice()),
("cldr-units-full/main/fr/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/fr/units.json").as_slice()),
("cldr-units-full/main/fil/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/fil/units.json").as_slice()),
("cldr-units-full/main/ja/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/ja/units.json").as_slice()),
("cldr-units-full/main/ru/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/ru/units.json").as_slice()),
("cldr-units-full/main/sr/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/sr/units.json").as_slice()),
("cldr-units-full/main/sr-Latn/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/sr-Latn/units.json").as_slice()),
("cldr-units-full/main/th/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/th/units.json").as_slice()),
("cldr-units-full/main/tr/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/tr/units.json").as_slice()),
("cldr-units-full/main/und/units.json", include_bytes!("../../../tests/data/cldr/cldr-units-full/main/und/units.json").as_slice()),
("cldr-person-names-full/main/ar/personNames.json", include_bytes!("../../../tests/data/cldr/cldr-person-names-full/main/ar/personNames.json").as_slice()),
("cldr-person-names-full/main/ar-EG/personNames.json", include_bytes!("../../../tests/data/cldr/cldr-person-names-full/main/ar-EG/personNames.json").as_slice()),
("cldr-person-names-full/main/bn/personNames.json", include_bytes!("../../../tests/data/cldr/cldr-person-names-full/main/bn/personNames.json").as_slice()),
Expand Down
31 changes: 31 additions & 0 deletions provider/datagen/src/transform/cldr/cldr_serde/units/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

//! Serde structs representing CLDR JSON units.json file.
//!
//! Sample file:
//! <https://github.com/unicode-org/cldr-json/blob/master/cldr-json/cldr-units-full/main/en/units.json>

use serde::Deserialize;
use std::collections::BTreeMap;

#[derive(PartialEq, Debug, Deserialize)]
pub struct UnitsData {
long: BTreeMap<String, String>,
short: BTreeMap<String, String>,
narrow: BTreeMap<String, String>,
}

#[derive(PartialEq, Debug, Deserialize)]
pub struct Units {
pub units: UnitsData,
}

#[derive(PartialEq, Debug, Deserialize)]
pub struct LangUnits {
pub units: Units,
}

// uncomment when LocaleResource is used
// pub type Resource = super::super::LocaleResource<LangUnits>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

pub(in crate::provider) mod data;
pub(in crate::provider) mod info;
4 changes: 4 additions & 0 deletions provider/datagen/src/transform/cldr/units/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

Loading
Loading