-
Notifications
You must be signed in to change notification settings - Fork 80
(@fluent/bundle) Forbid setting NUMBER's currency #464
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
Conversation
I added a second commit which changes the silent error behavior to an explicit one: the |
Oh rabbit hole, where are you when I need you? Oh, nice, there you are. I'd go as far as to whitelist valid arguments. But that's hard for backwards compat. The story is full of sadness, like plain calls to Note, there's already pre-existing documentation on restricting the options in https://projectfluent.org/fluent/guide/functions.html. I'd blacklist |
Nice documentation find. It looks it was written a long time ago, in a rather wishful tone :) If I'm understanding correctly, you're suggest to do the following?
I like this, but I'm afraid of breaking a combination of
FWIW, I haven't found anything like that in gecko-strings not in l10n-central. |
I changed the approach again to explicitly listing all allowed options, and silently ignoring all other options. This approach gives us good fallback for both unknown and forbidden options, and lets us strictly control allowed options in the future, too. |
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.
Thanks, the design looks right.
I'd be more restrictive on params that can lead to different meanings for the same number.
The tests are probably OK, but they're also all over the place. When we think about tests and their usefulness for other resolvers, we should make sure that details of the NUMBER
and DATETIME
implemetations are restricted to as few test files/cases as possible.
Thanks, @Pike. I agree about being more restrictive in terms of which options are allowed; I pushed the changes you requested. Good points about the tests, too. |
If one of the named arguments passed into
NUMBER
iscurrency
, we should remove it from the options bag. Right now this PR just ignores it silently, but perhaps it would be better to explicitly throw inNUMBER
instead. @Pike, wdyt?I also wonder if we should disallow
NUMBER
'sstyle
, as well. Are there scenarios when we'd want the localization to choose a different style (e.g.percent
) than the base (e.g.currency
)? I guess one such example is when the base is not explicitly defined in the source, in which casedecimal
is used. This can happen in the declarative bindings where there's no way to pass an instance ofFluentNumber
(like inDOMLocalization
).