-
Notifications
You must be signed in to change notification settings - Fork 100
ICU4x number formatting #303
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
Open
JasperDeSutter
wants to merge
7
commits into
projectfluent:main
Choose a base branch
from
JasperDeSutter:icu-number-formatting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2a8f7d
add DataProvider argument to Memoizable
JasperDeSutter 80a88fb
use icu4x for number formatting
JasperDeSutter ca9d8e6
add missing options for FluentNumber use_grouping
JasperDeSutter 435bf1e
add FluentNumber grouping test
JasperDeSutter 1564a02
handle minimum_integer_digits and maximum_significant_digits
JasperDeSutter 55f6483
use workspace versions for icu crates
JasperDeSutter 5812fda
add baked ICU4X provider to fluent-bundle
JasperDeSutter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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(FluentIcuDataProvider)); | ||
/// ``` | ||
pub use BakedDataProvider as FluentIcuDataProvider; | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.