DevHeads.net

Review Request 114889: Fix KIO::convertSize(...) returning string with "(I18N_ARGUMENT_MISSING)" inside

Review request for kdelibs.

Repository: kio

Description
Seems the code behind i18n() in kf5 does not like %-placeholders without any arguments passed in the i18n call. And thus inserts the warning.
(Effect can be seen e.g. in Okteta's File Info tool).

Attached patch fixes that, by delaying the argument substitution as proposed in <a href="http://api.kde.org/frameworks-5.x-api/frameworks-apidocs/ki18n/html/prg_guide.html#spec_usage" title="http://api.kde.org/frameworks-5.x-api/frameworks-apidocs/ki18n/html/prg_guide.html#spec_usage">http://api.kde.org/frameworks-5.x-api/frameworks-apidocs/ki18n/html/prg_...</a>

Diffs
src/core/global.cpp 42f453b

Diff: <a href="https://git.reviewboard.kde.org/r/114889/diff/" title="https://git.reviewboard.kde.org/r/114889/diff/">https://git.reviewboard.kde.org/r/114889/diff/</a>

Testing
Results of KIO::convertSize(...) displays fine in Okteta with the patch.

Thanks,

Friedrich W. H. Kossebau

Comments

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Friedrich W. H.... at 01/07/2014 - 12:24

(Updated Jan. 7, 2014, 4:24 p.m.)

Review request for kdelibs.

Changes
Updated patch to follow Chusslove's proposal for runtime performance improvement.

Repository: kio

Description (updated)
Seems the code behind i18n() in kf5 does not like %-placeholders without any arguments passed in the i18n call. And thus inserts the warning.
(Effect can be seen e.g. in Okteta's File Info tool).

Attached patch fixes that, by passing as argument a string with an argument placeholder again.

Diffs (updated)
src/core/global.cpp 42f453b

Diff: <a href="https://git.reviewboard.kde.org/r/114889/diff/" title="https://git.reviewboard.kde.org/r/114889/diff/">https://git.reviewboard.kde.org/r/114889/diff/</a>

Testing
Results of KIO::convertSize(...) displays fine in Okteta with the patch.

Thanks,

Friedrich W. H. Kossebau

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Friedrich W. H.... at 01/08/2014 - 06:43

(Updated Jan. 8, 2014, 10:43 a.m.)

Status
This change has been marked as submitted.

Review request for kdelibs.

Repository: kio

Description
Seems the code behind i18n() in kf5 does not like %-placeholders without any arguments passed in the i18n call. And thus inserts the warning.
(Effect can be seen e.g. in Okteta's File Info tool).

Attached patch fixes that, by passing as argument a string with an argument placeholder again.

Diffs
src/core/global.cpp 42f453b

Diff: <a href="https://git.reviewboard.kde.org/r/114889/diff/" title="https://git.reviewboard.kde.org/r/114889/diff/">https://git.reviewboard.kde.org/r/114889/diff/</a>

Testing
Results of KIO::convertSize(...) displays fine in Okteta with the patch.

Thanks,

Friedrich W. H. Kossebau

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Commit Hook at 01/08/2014 - 06:43

This review has been submitted with commit 149fd780c71b3d8d3d4098f43f6cb746a3ef6ada by Friedrich W. H. Kossebau to branch master.

- Commit Hook

On Jan. 7, 2014, 4:24 p.m., Friedrich W. H. Kossebau wrote:

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Chusslove Illich at 01/08/2014 - 05:20

Ship it!

Ship It!

- Chusslove Illich

On Jan. 7, 2014, 5:24 p.m., Friedrich W. H. Kossebau wrote:

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Chusslove Illich at 01/07/2014 - 10:39

src/core/global.cpp
<https://git.reviewboard.kde.org/r/114889/#comment33517>

The messages are no longer dumb (i.e. they have proper argument substitution), so all these comments should be removed.

- Chusslove Illich

On Jan. 6, 2014, 8 p.m., Friedrich W. H. Kossebau wrote:

Re: Review Request 114889: Fix KIO::convertSize(...) returning s

By Chusslove Illich at 01/07/2014 - 05:30

This code was originally like this (more or less), but someone complained
about performance of unit formatting. Then the code was switched away from
normal i18n calls, to use an internal low-level method of KLocale that would
fetch translation only once and cache it, later only substituting the
argument. When splitting into frameworks, this internal method was no longer
available, so the quick switch back to normal i18n left it in this semi-
correct state. The question now is whether to use correct i18n, as in your
patch, or to go back to a caching solution.

Without that low-level method, the caching solution would go by substituting
right away the literal "%1" as the argument (e.g.
i18nc("size in 10^6 bytes", "%1 MB", QString::fromLatin1("%1"));), caching
such translation, and subsequently using .arg on the cached translations
(similarly to that in klocale_kde.cpp in KDE 4).

- Chusslove Illich

On Jan. 6, 2014, 8 p.m., Friedrich W. H. Kossebau wrote: