Bug 462261 - Only one form of "minutes ago"
Summary: Only one form of "minutes ago"
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.100.0
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-26 10:25 UTC by NSLW
Modified: 2022-12-17 14:29 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.102


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NSLW 2022-11-26 10:25:21 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
In https://lxr.kde.org/source/frameworks/kcoreaddons/src/lib/util/kformatprivate.cpp at 512nd line there is a line
"return tr("%1 minutes ago").arg(minutesToNow);"
It's unfriendly for languages where e.g. "2 minutes ago" is translated differently than "30 minutes ago". Please fix this. Thank you in advance.


STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2022-11-30 19:26:27 UTC
Maybe we can use i18np() here?
Comment 2 Luigi Toscano 2022-11-30 20:41:38 UTC
kcoreaddons is tier1, sadly, so Qt only
Comment 3 Méven 2022-12-01 09:42:54 UTC
We can perhaps mitigate this with 
`if (minutesToNow == 30) {` and as many branches as necessary to better accommodate different languages.

@NSLW can you make recommendation where does your language needs different translation based on the number of minutes.

@NSLW What is the your language btw ?
Comment 4 Luigi Toscano 2022-12-01 10:01:25 UTC
(In reply to Méven from comment #3)
> We can perhaps mitigate this with 
> `if (minutesToNow == 30) {` and as many branches as necessary to better
> accommodate different languages.

Wouldn't that be like rewriting the logic of plural forms which is already in gettext? 

Anyway, Qt, should be able to handle this:
https://doc.qt.io/qt-5/i18n-source-translation.html#handling-plurals
https://doc.qt.io/archives/qt-5.12/i18n-plural-rules.html
Comment 5 Bug Janitor Service 2022-12-01 10:19:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/271
Comment 6 Méven 2022-12-01 10:55:32 UTC
Git commit f284392d30ded03c8142f6baad0335e67fd53c8a by Méven Car.
Committed on 01/12/2022 at 10:55.
Pushed by meven into branch 'bug-462261'.

Better Pluralize 'n minutes ago'

M  +1    -1    autotests/kformattest.cpp
M  +1    -1    src/lib/util/kformatprivate.cpp

https://invent.kde.org/frameworks/kcoreaddons/commit/f284392d30ded03c8142f6baad0335e67fd53c8a
Comment 7 NSLW 2022-12-01 15:33:58 UTC
(In reply to Méven from comment #3)
> We can perhaps mitigate this with 
> `if (minutesToNow == 30) {` and as many branches as necessary to better
> accommodate different languages.
> 
> @NSLW can you make recommendation where does your language needs different
> translation based on the number of minutes.
> 
> @NSLW What is the your language btw ?

It's Polish and it goes like this:
1 minuta
2-4 minuty
5-21 minut
22-24 minuty
25-31 minut
(In reply to Méven from comment #3)
> We can perhaps mitigate this with 
> `if (minutesToNow == 30) {` and as many branches as necessary to better
> accommodate different languages.
> 
> @NSLW can you make recommendation where does your language needs different
> translation based on the number of minutes.
> 
> @NSLW What is the your language btw ?

(In reply to Méven from comment #3)
> We can perhaps mitigate this with 
> `if (minutesToNow == 30) {` and as many branches as necessary to better
> accommodate different languages.
> 
> @NSLW can you make recommendation where does your language needs different
> translation based on the number of minutes.
> 
> @NSLW What is the your language btw ?

It's Polish and it goes like this:
1 minuta
2-4 minuty
5-21 minut
22-24 minuty
25-31 minut
...

I think that your idea is good. There are only three cases in this case for Polish.

"%n minute(s)" is in general not a good solution because in Polish you make plural forms not by appending a single letter like in English but by replacing letters.

Thank you all for interest in fixing this bug.
Comment 8 Méven Car 2022-12-17 10:45:35 UTC
Git commit 752ad70df69fc98ae35ba59313e5633b200150b8 by Méven Car, on behalf of Méven Car.
Committed on 17/12/2022 at 10:41.
Pushed by meven into branch 'master'.

Better Pluralize 'n minutes ago'
FIXED-IN: 5.102

M  +1    -1    autotests/kformattest.cpp
M  +4    -1    src/lib/util/kformatprivate.cpp

https://invent.kde.org/frameworks/kcoreaddons/commit/752ad70df69fc98ae35ba59313e5633b200150b8
Comment 9 NSLW 2022-12-17 13:45:54 UTC
It's still not fixed. See comment #7.
Comment 10 Luigi Toscano 2022-12-17 13:49:54 UTC
(In reply to NSLW from comment #9)
> It's still not fixed. See comment #7.

Why? It is now handled by the translation system, which should provide multiple forms for Polish. Of course this will be visible in the next release of Frameworks (5.102).
Comment 11 NSLW 2022-12-17 14:04:02 UTC
(In reply to Luigi Toscano from comment #10)
> (In reply to NSLW from comment #9)
> > It's still not fixed. See comment #7.
> 
> Why? It is now handled by the translation system, which should provide
> multiple forms for Polish. Of course this will be visible in the next
> release of Frameworks (5.102).

He changed "minutes" to "minute(s)", and it will appear as a single translation unit in the translation system. It would need to have three translation units for it to be fixed.
Comment 12 Luigi Toscano 2022-12-17 14:09:00 UTC
(In reply to NSLW from comment #11)
> (In reply to Luigi Toscano from comment #10)
> > (In reply to NSLW from comment #9)
> > > It's still not fixed. See comment #7.
> > 
> > Why? It is now handled by the translation system, which should provide
> > multiple forms for Polish. Of course this will be visible in the next
> > release of Frameworks (5.102).
> 
> He changed "minutes" to "minute(s)", and it will appear as a single
> translation unit in the translation system. It would need to have three
> translation units for it to be fixed.

Again, that's the English string, which has only two forms. The translation system takes care of the plural forms, just like it happens with all the other strings. If it didn't work, you wouldn't have any properly translated string. Please check the original English strings when multiple cases are involved and the translation work, and you will see that it is exactly like this. 

After the change, the translation in the pl file is:

#. @item:intext %1 is a whole number
#: lib/util/kformatprivate.cpp:515
#, fuzzy, qt-format
#| msgctxt "KFormat|"
#| msgid "%1 minutes ago"
msgctxt "KFormat|"
msgid "%n minute(s) ago"
msgid_plural "%n minute(s) ago"
msgstr[0] "%1 minuty temu"
msgstr[1] "%1 minuty temu"
msgstr[2] "%1 minuty temu"

which needs to be fixed by the Polish translators of course. It will be fixed in the next release.
Comment 13 NSLW 2022-12-17 14:29:42 UTC
(In reply to Luigi Toscano from comment #12)
> (In reply to NSLW from comment #11)
> > (In reply to Luigi Toscano from comment #10)
> > > (In reply to NSLW from comment #9)
> > > > It's still not fixed. See comment #7.
> > > 
> > > Why? It is now handled by the translation system, which should provide
> > > multiple forms for Polish. Of course this will be visible in the next
> > > release of Frameworks (5.102).
> > 
> > He changed "minutes" to "minute(s)", and it will appear as a single
> > translation unit in the translation system. It would need to have three
> > translation units for it to be fixed.
> 
> Again, that's the English string, which has only two forms. The translation
> system takes care of the plural forms, just like it happens with all the
> other strings. If it didn't work, you wouldn't have any properly translated
> string. Please check the original English strings when multiple cases are
> involved and the translation work, and you will see that it is exactly like
> this. 
> 
> After the change, the translation in the pl file is:
> 
> #. @item:intext %1 is a whole number
> #: lib/util/kformatprivate.cpp:515
> #, fuzzy, qt-format
> #| msgctxt "KFormat|"
> #| msgid "%1 minutes ago"
> msgctxt "KFormat|"
> msgid "%n minute(s) ago"
> msgid_plural "%n minute(s) ago"
> msgstr[0] "%1 minuty temu"
> msgstr[1] "%1 minuty temu"
> msgstr[2] "%1 minuty temu"
> 
> which needs to be fixed by the Polish translators of course. It will be
> fixed in the next release.

Ok, thanks for the explanation. It seems that I did not understand the patch. BTW. Thanks for the fix.