Closed Xiretza closed 6 months ago
Will review, but definitely waiting on #347 before we can actually do anything about this ;-) Thanks for taking the time to contribute.
I was reviewing this and went ahead and rebased to fix the commit messages and also threw in the #[derive(Default)
cleanup too.
A couple of notes:
In #259, @gregtatum mentioned using kind
rather than r#type
... not sure if that's relevant here or not.
Also, https://projectfluent.org/fluent/guide/functions.html#number lists a number of other options. Should any of them be supported as part of this? (or a follow-up issue filed to track that they're missing?)
In #259, @gregtatum mentioned using
kind
rather thanr#type
... not sure if that's relevant here or not.
I changed that back because I wanted to avoid using a different term in Rust than is used everywhere else.
Also, https://projectfluent.org/fluent/guide/functions.html#number lists a number of other options. Should any of them be supported as part of this? (or a follow-up issue filed to track that they're missing?)
Those should already be handled here: https://github.com/projectfluent/fluent-rs/blob/f6168c8101af7dc39dbfbed286d2b6f9e7271fd9/fluent-bundle/src/types/number.rs#L79
I would have preferred "kind" too, but given that the Guide and Python both already use "type" I do agree that we should stick with that for now. If changing this is a priority we should hurry up and suggest the fix in the guide and spec, then implement it that way in Rust and Python can take their time about adapting. Honestly I'm not sure it's worth it just to avoid a reserved word we can easily use raw strings for anyway.
There's a doctest, I can add integration tests too if desired.
Back to you @waywardmonkeys. Was there something else specific you thought should be tested?
I'd probably go with something like the Python tests: https://github.com/projectfluent/python-fluent/pull/193/files#diff-30d1a24a3e67774b5d192acb1cd3f532961bae49746db23ab7b7962e7cb8a25d
I've added an integration test.
I just tried main
and still getting Unknown function: NUMBER()
, am I missing something?
Also maximumFractionDigits
doesn't seem to be supported as described in the docs, am I right?
This is all a bit confusing, especially with https://github.com/projectfluent/fluent-rs/issues/19 and https://github.com/projectfluent/fluent-rs/issues/313 closed as completed.
UPD: I didn't call add_builtins
, why would it not be used by default?
Followup to #259. Adds the
type
property toFluentNumberOptions
and makes it available through a newNUMBER()
built-in fluent function. Built-ins (currently justNUMBER()
) are added to the bundle usingFluentBundle::add_builtins()
.Cc #19.