Skip to content
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

Fix pattern-matching example to use "1" on left-hand side #20

Merged
merged 2 commits into from
Apr 28, 2023

Conversation

catamorphism
Copy link
Contributor

If I'm following this example correctly, the left-hand side of the rule here needs to be 1, not one, since the JS code passes an object whose count property is "1". If I'm understanding MF2 pattern-matching semantics correctly, the comparison between a selector (or rather, the result of evaluating the selector) and an nmtoken key is just a string comparison. So the MF2 code here would evaluate to "You have 1 new notifications", not "You have one new notification", which in turn doesn't match the comment in the JS code.

@eemeli
Copy link
Member

eemeli commented Apr 28, 2023

This change makes sense, but not for the reason you propose. The numerical value 1 will in fact match a key one, as numbers are compared not only according to exact match, but also according to the number's plural category in the current locale; English uses one and other.

Now, the reason why this change still makes sense is that the content of the message is specific to the exact value, rather than the category. In English, those are the same, but in many other locales, one may be applied to other values as well, such as 11 or 21. English ordinal plurals, for instance, use one for 21, 31, etc. And in this case, the example message refers to one new notification rather than {$count} new notification.

@eemeli eemeli merged commit 49a9d7f into tc39:main Apr 28, 2023
@catamorphism catamorphism deleted the notifications-example branch May 3, 2023 03:34
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.

None yet

2 participants