-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add baked ICU4X provider to fluent-bundle
- Loading branch information
1 parent
55f6483
commit 15f5d13
Showing
9 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated | ||
impl_any_provider ! (BakedDataProvider) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated | ||
# [doc = r" Marks a type as a data provider. You can then use macros like"] # [doc = r" `impl_core_helloworld_v1` to add implementations."] # [doc = r""] # [doc = r" ```ignore"] # [doc = r" struct MyProvider;"] # [doc = r" const _: () = {"] # [doc = r#" include!("path/to/generated/macros.rs");"#] # [doc = r" make_provider!(MyProvider);"] # [doc = r" impl_core_helloworld_v1!(MyProvider);"] # [doc = r" }"] # [doc = r" ```"] # [doc (hidden)] # [macro_export] macro_rules ! __make_provider { ($ name : ty) => { # [clippy :: msrv = "1.67"] impl $ name { # [doc (hidden)] # [allow (dead_code)] pub const MUST_USE_MAKE_PROVIDER_MACRO : () = () ; } } ; } # [doc (inline)] pub use __make_provider as make_provider ; # [macro_use] # [path = "macros/decimal_symbols_v1.rs.data"] mod decimal_symbols_v1 ; # [doc (inline)] pub use __impl_decimal_symbols_v1 as impl_decimal_symbols_v1 ; |
2 changes: 2 additions & 0 deletions
2
fluent-bundle/src/icu4x_data/macros/decimal_symbols_v1.rs.data
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated | ||
include ! ("macros.rs") ; macro_rules ! impl_data_provider { ($ provider : ty) => { make_provider ! ($ provider) ; impl_decimal_symbols_v1 ! ($ provider) ; } ; } # [allow (unused_macros)] macro_rules ! impl_any_provider { ($ provider : ty) => { # [clippy :: msrv = "1.67"] impl icu_provider :: AnyProvider for $ provider { fn load_any (& self , key : icu_provider :: DataKey , req : icu_provider :: DataRequest) -> Result < icu_provider :: AnyResponse , icu_provider :: DataError > { match key . hashed () { h if h == < icu::decimal :: provider :: DecimalSymbolsV1Marker as icu_provider :: KeyedDataMarker > :: KEY . hashed () => icu_provider :: DataProvider :: < icu::decimal :: provider :: DecimalSymbolsV1Marker > :: load (self , req) . map (icu_provider :: DataResponse :: wrap_into_any_response) , _ => Err (icu_provider :: DataErrorKind :: MissingDataKey . with_req (key , req)) , } } } } } # [clippy :: msrv = "1.67"] pub struct BakedDataProvider ; impl_data_provider ! (BakedDataProvider) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extern crate alloc; | ||
|
||
// to regerate the icu4x_data module, run from the root of the project: | ||
// cargo build --examples | ||
// rm -r fluent-bundle/src/icu4x_data | ||
// icu4x-datagen --keys-for-bin target/debug/examples/functions --format mod --locales full -o fluent-bundle/src/icu4x_data | ||
// for more information: https://github.com/unicode-org/icu4x/blob/79480dfbafdedf6cc810e4bfb0770f3268ff86ab/tutorials/data_management.md | ||
include!("./icu4x_data/mod.rs"); | ||
impl_any_provider!(BakedDataProvider); | ||
|
||
/// ICU data provider | ||
/// | ||
/// Fluent uses ICU4X data for formatting purposes, like number formatting. | ||
/// Use FluentIcuDataProvider to add all ICU data needed by fluent-bundle. | ||
/// You can bring your own provider if you don't need all locales, or have one in your project already. | ||
/// | ||
/// Example: | ||
/// ``` | ||
/// use fluent_bundle::{FluentBundle, FluentIcuDataProvider, FluentResource}; | ||
/// use unic_langid::langid; | ||
/// | ||
/// let langid = langid!("en-US"); | ||
/// let mut bundle: FluentBundle<FluentResource> = FluentBundle::new(vec![langid]); | ||
/// bundle.set_icu_data_provider(Box::new(fluent_bundle::FluentIcuDataProvider)); | ||
/// ``` | ||
pub use BakedDataProvider as FluentIcuDataProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters