-
Notifications
You must be signed in to change notification settings - Fork 338
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
Fall back to 'other' if a plural form is missing #2921
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71483a7
Set the language for the 'Translated' example page
36degrees c082fd3
Add failing test for Character Count errors
36degrees 643ce54
Fall back to `other` if a plural form is missing
36degrees 588d027
Move translation-checking logic to getPluralSuffix
36degrees 91d52c4
Avoid using 'rule' to mean two different things
36degrees 99f72ae
Improve test coverage of `getPluralSuffix`
36degrees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm seeing
.many
,.few
and.two
logged (not just.one
)Shall we do one of those fancy
it.each([])
and make sure each plural form has a test?Looks good
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 came up on Slack, so bringing over the points here
.two
,.few
,.many
warnings, for all locales?.two
,.few
,.many
warnings, for English only?👆 Above would be the Character Count defaults if we needed all strings
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.
Different plural forms are required depending on which locale the Character Count is in.
When in the default 'en' locale, only 'one' and 'other' are required.
So, I think the answers are:
en
locale, because we have all of the plural forms we need to localise in English ('one' and 'other')en
locale – we'd expect if the locale is something other thanen
that we'd have a different set of translations passed with the correct plural forms for the locale. This PR is trying to address the edge case where that doesn't happen.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.
@36degrees Perfect, thanks for the answers
Do you want to add tests to confirm?
.two
,.few
,.many
.two
,.few
,.many
We've got this one already, but won't harm to document this decision about the others in test form
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.
I'm wary of testing for specific locales as it feels like we're starting to test the implementation of
Intl.PluralRules.select
rather than our code.The reason that we shouldn't output any warnings for the
en
locale is because of how the class interacts with the config for the character count – there is nothing happening in the I18n class itself that means we treat theen
locale any differently to any other locale.I can add comments to the tests to try and make it clearer how the config we're passing in tests specific scenarios, if that'd help?
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.
Yeah, makes sense
I like to think if a less experienced developer touches these lines in future, and they break something, the tests should be there to explain exactly why the change broke something—gives them a safety net.
Also, if we fix a Welsh bug, add a Welsh test case 😆
If it feels better in the Puppeteer tests, further away from I18n, can do that?
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.
I've added a failing test to the Character Count component in c757025.