#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.
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.
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.
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
| 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)) { |
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