Skip to content

Use icu_list to emit list in diagnostics. #2

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
wants to merge 2 commits into
base: master_after_tinystr_update
Choose a base branch
from

Conversation

crlf0710
Copy link
Owner

No description provided.

@@ -539,3 +541,47 @@ impl From<Vec<Span>> for MultiSpan {
MultiSpan::from_spans(spans)
}
}

#[macro_export]
macro_rules! pluralize {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: we should be using icu_pluralrules for this

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fluent also supports this built-in

} else {
let data_provider = rustc_baked_icu_data::baked_data_provider();
let locale = icu_locid::locale!("en").into();
let list_formatter = icu_list::ListFormatter::try_new_and_with_length_unstable(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: ideally the list formatter is built once and stored in the session or something

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically it needs to be stored alongside the fluent stuff

assert!(value_count > 0);

if value_count > spread_limit {
format!("multiple {descr}{s}", s = pluralize!(value_count),)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the descr stuff shouldn't be handled here. if we want to handle it, it ought to be handled via Fluent's builtin support for pluralization

@crlf0710
Copy link
Owner Author

Thanks for the review! I'll dig into the usage part of the diagnostic infrastructure, before addressing these review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants