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

#539 PrettyTime Missing Unit Workaround #687

Merged
merged 2 commits into from
Jun 19, 2023
Merged

#539 PrettyTime Missing Unit Workaround #687

merged 2 commits into from
Jun 19, 2023

Conversation

lbenedetto
Copy link
Contributor

@lbenedetto lbenedetto commented Jun 15, 2023

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

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)) {
Copy link
Member

@dessalines dessalines Jun 16, 2023

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.

Copy link
Contributor Author

@lbenedetto lbenedetto Jun 16, 2023

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.

Copy link
Member

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
Copy link
Member

@dessalines dessalines left a 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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmk, thanks!

@dessalines dessalines merged commit 6a8b71b into LemmyNet:main Jun 19, 2023
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.

2 participants