-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Let Vec be used as an argument in fluent strings #106986
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. Please see the contribution instructions for more information. |
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
I think @Manishearth wanted to use ICU4X for this IIRC |
This uses the list support added in #104047 . Other than the "x more" part, which I couldn't figure out - is that even supported? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be done this way: to handle "or more" you should be having the logic in the fluent file, something like
mir_build_uncovered = {$truncated ->
[true] {$witnesses}
*[other] {$witnesses}, and more
} not covered
and the truncation logic being handled in Rust. Except that's not so straightforward since the list will already format with a , and
. You might need to define a fluent custom function that is able to do list formatting, cc @davidtwco. Unfortunatley it doesn't have a list type yet.
Furthermore, not all lists will want to be truncated. We should have a TruncatedDiagnosticList
type that has all this logic.
This would be easier if Fluent had builtin list formatting support (projectfluent/fluent#79)
I think the way to do this for now is have another internal list type (perhaps we can merge it all into StrList, which has And/Or and truncate/don't truncate options), and have it pull from a list_more = and {$count} more
Fluent key that's "global"
Thanks, I've just created a new type for it.
Where should this live? |
We could create a |
I'm not sure how to make it fit together though. I assume I'd need to get access to the bundle inside the |
Is it possible with the way we use |
An alternative approach would be to have some kind of
#[list]
attribute for the derive macro to use, or a newtype for doing this. I chose the current approach because it's what people will try first and it'd be nice to have it "Just Work" - there's no need to write or read documentation.