kformattest: Use plural suffix (s) consequently
Needs RevisionPublic

Authored by habacker on Aug 20 2018, 6:21 AM.

Details

Reviewers
aacid
Summary

Mixing plural '(s)' and translated 's' suffix could not be correct.

Diff Detail

Repository
R244 KCoreAddons
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 2016
Build 2034: arc lint + arc unit
habacker created this revision.Aug 20 2018, 6:21 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 20 2018, 6:21 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
habacker requested review of this revision.Aug 20 2018, 6:21 AM
habacker updated this revision to Diff 40038.Aug 20 2018, 9:54 AM
  • type fix in KFormatTest::formatDecimalDuration
  • missing plural fix in KFormatPrivate::formatDecimalDuration
aacid requested changes to this revision.Aug 21 2018, 10:00 PM

This is not how plurals for decimals work, they are always in plural.

This revision now requires changes to proceed.Aug 21 2018, 10:00 PM

According to the section'Handling of plurals' on http://doc.qt.io/qt-5/i18n-source-translation.html, for plurals an '(s)' is used instead of the 's' as suffx. You are refering to a different spec ?

According to the section'Handling of plurals' on http://doc.qt.io/qt-5/i18n-source-translation.html, for plurals an '(s)' is used instead of the 's' as suffx. You are refering to a different spec ?

Yes, that is for plurals, not for decimals.

1.3 days is not a plural in the sense described there[1], it's a decimal number and it follows different rules.

[1] see how n is an integer not a float

I see - Qt lacks support for choosing the correct translation string for floating point values like this:

qreal value = 1.0;
tr("%n second(s)", nullptr, value).

which should return 1.0 second

qreal value = 1.34;
tr("%n second(s)", nullptr, value).

which should return 1.34 seconds

qreal value = 0.0;
tr("%n second(s)", nullptr, value).

which should return 0.0 seconds

and for strings:

int decimalPlaces = 2;
qreal MSecsInSecond = 1000;
qreal msecs = 1000.0
return tr("%n second(s)").arg(m_locale.toString(msecs / (MSecsInSecond * 1.0), 'f', decimalPlaces));

which should return 1.00 second

int decimalPlaces = 2;
qreal MSecsInSecond = 1000;
qreal msecs = 1100.0
return tr("%n second(s)").arg(m_locale.toString(msecs / (MSecsInSecond * 1.0), 'f', decimalPlaces));

which should return 1.10 seconds

aacid added a comment.Aug 23 2018, 5:37 PM

I see - Qt lacks support for choosing the correct translation string for floating point values like this:

qreal value = 1.0;
 tr("%n second(s)", nullptr, value).

which should return 1.0 second

Are you sure about that? Most answer i find online say 1.0 seconds is the right way to write it, basically, because if you write 1.0 seconds is because you know it's not 1 second, but something that rounds to 1.0 seconds, i.e in the 0.96 to 1.04 range with a precision of one digit.

FWIW, "1.0 seconds" is what I've always been taught.

https://forum.wordreference.com/threads/decimals-plural-singular.2054431/#post-10279600 listed many public organisations that are using signular for values between 1 and -1.

https://forum.wordreference.com/threads/decimals-plural-singular.2054431/#post-10279600 listed many public organisations that are using signular for values between 1 and -1.

At this point, does it really matter though? Qt doesn't support what you want to do, so you need to convince them not us.