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.
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
Transformer for RelativeTimeFormat component #2822
Transformer for RelativeTimeFormat component #2822
Changes from 1 commit
8b7f542
4dd5487
9c46b25
cb50c7c
63fe73f
5bb203a
ef3db5c
e829e94
f7c7aab
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Thought: I'm wondering whether we want to slice this smaller. For example, I know ECMA-402 delays the unit choice to the format function, but should we be making it an option in the constructor instead? And how about the direction (past/future)? We're going to get some pretty big data keys out of this, which begs the question about whether we should be slicing more granularly.
It's OK to make constructors that load multiple data keys for convenience, of course.
One possible axis that is already in ECMA-402 is "numeric". If the user requests numeric: "always", then they shouldn't need to load the non-numeric data. So, we could maybe move that data into a separate data key.
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.
The data keys are pretty big currently with most of the fields being 'None'.
I'm in favour of splitting it further into at least | "unit" x "width" | data keys. This would remove the need for having an array of "RelativeTimePattern".
Then we can focus on an efficient representation of "PluralRulesCategory" => "Singular substitution pattern" mapping.
Using a "ZeroMap<PluralRulesCategory, SubstitutionPattern>" would be good as we don't store the unnecessary mappings but I haven't been able to make it work.
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.
Would be great to do unit x width (8*3). What do you think about unit x width x numeric (8*3*2)?
Yes, let's brainstorm the best representation for PluralCategory => Pattern.
There are some advantages to expanding to separate fields instead of using ZeroMap. Note that
None
fields do not take up much space in Postcard.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.
Thought: What is the full set of number offsets? In most locales it is -1, 0, 1; there are some that go to -2, -1, 0, 1, 2. This is an okay use of ZeroMap, but if there is never going to be more than -2 to 2, we may want to consider expanding that into the struct itself.
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.
The offsets are from [-2, 2].