-
Notifications
You must be signed in to change notification settings - Fork 169
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
#539 PrettyTime Missing Unit Workaround #687
#539 PrettyTime Missing Unit Workaround #687
Conversation
var prettyDate = prettyTime.formatDuration(date) | ||
|
||
// A bug in PrettyTime means that some languages (pl, ru, uk, kk) will not include any time unit | ||
if (prettyDate.matches(invalidPrettyDateRegex)) { |
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.
Where's the bug in prettytime? It seems pretty active. Definitely open up a PR over there, and reference it here, so that we don't always have to use this hack.
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 linked the pretty time bug report in the PR description.
But really, it's not so much a bug as a lack of support for these languages. For other languages, they have maps of words in those languages and logic to choose those words with the correct plurality and such.
However, for these four languages, the implementation does not contain any words or logic and just returns back whatever number was passed in.
So I don't think this is a quick fix for them.
I wrote this workaround here so that if/when the issue is fixed, it won't continue defaulting to English, it'll just become irrelevant.
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.
Mmmk, thanks!
A bug in PrettyTime causes four languages to not get any time units when formatted. We can work around this by detecting an invalid prettyDate (rather than hardcoding a list of broken languages) and switching to English formatting instead. ocpsoft/prettytime#259
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.
Thx for this!
var prettyDate = prettyTime.formatDuration(date) | ||
|
||
// A bug in PrettyTime means that some languages (pl, ru, uk, kk) will not include any time unit | ||
if (prettyDate.matches(invalidPrettyDateRegex)) { |
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.
Mmmk, thanks!
This is a workaround for #539
A bug in PrettyTime causes four languages to not get any time units when formatted.
We can work around this by detecting an invalid prettyDate (rather than hardcoding a list of broken languages) and switching to English formatting instead.
ocpsoft/prettytime#259