Bug 422166 - Large number of files can be displayed in scientific notation in copying notification
Summary: Large number of files can be displayed in scientific notation in copying noti...
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Notifications (show other bugs)
Version: 5.18.5
Platform: Ubuntu Linux
: NOR minor
Target Milestone: 1.0
Assignee: Kai Uwe Broulik
URL:
Keywords:
: 424289 429284 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-05-28 10:37 UTC by phd
Modified: 2023-05-17 02:40 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
plasma-copying-large-number-of-files-scientific-notation-bug.png (67.90 KB, image/png)
2020-05-28 10:37 UTC, phd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description phd 2020-05-28 10:37:23 UTC
Created attachment 128854 [details]
plasma-copying-large-number-of-files-scientific-notation-bug.png

SUMMARY
Number of files is sometimes displayed in scientific notation in copying notification:
en-US: "1.75219e+06 of 1,777,348 files"
pl-PL: "1,75219e+06 z 1'777'348 plików"
This happens when copying large number (1 to 2 million or more) of files.
Screenshot attached (Polish localization).

STEPS TO REPRODUCE
1. start copying large number (1 to 2 million) of files
2. show the details of the copying notification in Plasma

OBSERVED RESULT
Number of files is sometimes displayed in scientific notation in copying notification.

EXPECTED RESULT
Number of files should always be displayed as an integer number.

SOFTWARE/OS VERSIONS
Linux: Ubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Comment 1 phd 2020-05-28 10:52:27 UTC
I have investigated this issue a bit.

This label is displayed by 
/usr/share/plasma/plasmoids/org.kde.plasma.notifications/contents/ui/JobDetails.qml
from plasma-workspace:

>    text: {
>        var processed = jobDetails["processed" + modelData];
>        var total = jobDetails["total" + modelData];
>
>        if (processed > 0 || total > 1) {
>            if (processed > 0 && total > 0 && processed <= total) {
>                switch(modelData) {
>                case "Bytes":
>                    return i18ndc("plasma_applet_org.kde.plasma.notifications", "How many bytes have been copied", "%2 of %1",
>                        KCoreAddons.Format.formatByteSize(total),
>                        KCoreAddons.Format.formatByteSize(processed))
>                case "Files":
>                    return i18ndcp("plasma_applet_org.kde.plasma.notifications", "How many files have been copied", "%2 of %1 file", "%2 of %1 files",
>                                    total, processed);
>                case "Directories":
>                    return i18ndcp("plasma_applet_org.kde.plasma.notifications", "How many dirs have been copied", "%2 of %1 folder", "%2 of %1 folders",
>                                    total, processed);
>                }
>            } else {
>                switch(modelData) {
>                case "Bytes":
>                    return KCoreAddons.Format.formatByteSize(processed || total)
>                case "Files":
>                    return i18ndp("plasma_applet_org.kde.plasma.notifications", "%1 file", "%1 files", (processed || total));
>                case "Directories":
>                    return i18ndp("plasma_applet_org.kde.plasma.notifications", "%1 folder", "%1 folders", (processed || total));
>                }
>            }
>        }
>
>        return "";
>    }

If you want to reproduce this issue easily, just do this and start any copying job lasting long enough:

>        var processed = jobDetails["processed" + modelData] + 10000000;
>        var total = jobDetails["total" + modelData] + 10000000;

And now comes the fun part. This seems to a very strange problem with i18ndcp() formatting.
"%2 of %1 files" always fails for the first placeholder (%2), but never for the second one.
You can even reorder the arguments you supply to that function!:

>                    return i18ndcp("plasma_applet_org.kde.plasma.notifications", "How many files have been copied", "%2 of %1 file", "%2 of %1 files",
>                                    /* total , processed */ processed, total);

and still it will fail only for the first placeholder (%2), despite the fact it now displays a number which was previously formatted fine as the second placeholder (%1).
So it is not a problem with the number supplied, but somewhere deeper in i18ndcp() formatting logic.
Comment 2 Kai Uwe Broulik 2020-05-28 11:09:01 UTC
i18n (KLocalizedString) does format numbers since recently, maybe it should be changed to never use scientific notation?
Comment 3 Patrick Silva 2021-06-10 23:50:47 UTC
*** Bug 424289 has been marked as a duplicate of this bug. ***
Comment 4 mail 2022-12-26 22:54:16 UTC
*** Bug 429284 has been marked as a duplicate of this bug. ***