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

Fix for formatDuration method for russian locale #260

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

Snow4DV
Copy link
Contributor

@Snow4DV Snow4DV commented Jun 22, 2023

This PR partly addresses issue #259 for russian language:

In english locale formatDuration() method works correctly returning "12 days"/"1 week"/"1 year" and etc. format() method also returns the correct thing: "12 days ago"/"in 1 week"/"1 year ago" but there's was a problem with russian locale:

while method format returned "12 дней назад" (12 days ago)/"1 минуту назад" (1 minute ago) there was a problem with formatDuration (and it wasn't even included in unit tests) - it returned String.valueOf(12) or "12"/"1" instead of desired "12 дней"/"1 минута"

This PR fixes this problem for russian locale.

Some work should still be done to support this for kk, uk, pl locales - these locales basically shared the same code.

P.S. In order to distinguish "1 минута" (or "1 minute") received by formatDuration from "через 1 минуту"/( or "in 1 minute") {there are some other cases of this but there are really few of them} i used a little bit hacky solution so some changes might be considered so format method would receive some hint whether result would be decorated or not. Not really important - just a small note (see comment in the code)

@Snow4DV
Copy link
Contributor Author

Snow4DV commented Jun 22, 2023

I am concerned about it because it caused issues for jerboa (lemmy client) when polish/russian/ukrainian users got incorrectly represented duration: LemmyNet/jerboa#539

@Snow4DV Snow4DV marked this pull request as draft June 22, 2023 14:34
@Snow4DV Snow4DV marked this pull request as ready for review June 22, 2023 14:46
@lincolnthree
Copy link
Member

lincolnthree commented Jun 23, 2023

Hey! Thank you for reporting this and for sending a PR. I will review it ASAP and get a new release put out if everything looks good. Much appreciated :)

@lincolnthree
Copy link
Member

Just took a quick glance. Confirms my suspicions. Russian is a complicated language :D

@Snow4DV
Copy link
Contributor Author

Snow4DV commented Jun 23, 2023

Yeah it is indeed :)) Same thing applies to Polish, Ukrainian

@lincolnthree
Copy link
Member

@Snow4DV Any chance you know how to fix the other languages as well? Or know someone who does? :D Unfortunately I am not at all familiar with them, and I don't personally maintain the translations (by necessity, lol).

@lincolnthree lincolnthree merged commit c933ab9 into ocpsoft:master Jun 23, 2023
@lincolnthree
Copy link
Member

Looks great, tests pass, let's go!

@lincolnthree
Copy link
Member

lincolnthree commented Jun 23, 2023

Released 5.0.7.Final -- Should be in central overnight. Thank you again!!

@Snow4DV
Copy link
Contributor Author

Snow4DV commented Jun 23, 2023

Great! :) Thank you for quick merge!)

@Snow4DV
Copy link
Contributor Author

Snow4DV commented Jun 23, 2023

@Snow4DV Any chance you know how to fix the other languages as well? Or know someone who does? :D Unfortunately I am not at all familiar with them, and I don't personally maintain the translations (by necessity, lol).

I'll have a look at it soon - if i understood everything correctly, rules are pretty similar at least for polish and ukrainian to me. Will use translator to make sure :)

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