[PATCH] Add support for JEDEC/metric standards to KLocale::formatByteSize

Karl Ove Hufthammer karl at huftis.org
Sun Jul 12 16:08:11 BST 2009


Michael Pyne:

> 1) Add a GUI to localization settings KCM to allow the user to select
> their preferred unit style.

It should also be possible for the translators to set the default value for 
their language.

> 2) Go through the KDE applications we maintain and use formatByteSize
> where appropriate.  What I mean by that is that whenever possible we
> should respect the user's units.  However, when we report download speed,
> that should be in decimal given existing practice, even for users with
> JEDEC.

Why? Is there a compelling reason for mixing different units?

For cases where there is a fixed set of values for units, such as in CD-ROM 
sizes and MP3 compression (128 ‘kbps’, 160 ‘kbps’, 320 ‘kbps’ – I haven’t 
looked up whether the ‘kbps’ refers to 1000 bits or 1024 bits), it is 
reasonable to always use the ‘standard’ *numbers* (but preferably the SI 
symbols, e.g., ‘kb/s’). But where there are no such standard fixed set of 
values, what is the reason for a confusing mix of numbers and symbols?

For example, when you download data with a speed of 1 MB/s for 60 seconds, 
why should you end up with a file of 57.2 MiB? Isn’t it much more consistent 
to download data with with a speed of 1 MiB/s for 60 seconds and end up with 
a file of 60 MiB?

And with the ‘mixing’ solution, should the download dialogue show both 
decimal and binary units – decimal numbers for the speed and binary units 
for the amount transferred?!

Also note that the (*in theory*) unambigious use of KB (uppercase K) for 
indicating 1024 bytes as compared to kB (lowercase k) for 1000 bytes only 
works for 1000/1024. For MiBs, GiBs &c. we have no such correspondence.

Or are you suggesting that MB should refer to 1024 × 1024 bytes for file 
sizes and 1000 × 1000 for download speeds, and that this will be easier for 
everyone to understand than always using unambiguous MiB units?

> When reporting hard disk capacity (i.e. in KDiskFree) we should
> use (or at least show) decimal units even for IEC or JEDEC.

So the numbers (excluding the symbols) displayed should always differ 
between kdf and df (-h)?

> 3) I can't find the email right now but I do remember reading an email
> from someone on our i18n teams who was having trouble with the various
> applications using their own units (sometimes they meant decimal,
> sometimes binary, etc.)

Since this is crossposted to the I18N list, here’s the content of that 
e-mail, to make it easier to quote for translators:

As a translator of KDE, let me chime in.

First, I’m very happy to see that KDE (at least Konqueror and Dolphin) has 
finally changed to properly labeling the units as KiB, MiB, etc.

For us translators, this has been a continuing source of frustration. We 
wish to provide the correct translations of the units (KiB if it’s a KiB, kB 
if it’s a kB, kb if it’s a kb, etc.) as a service to the users, even if the 
original strings are incorrect. However, the inconsistent use of the letters 
make this very time-consuming, and sometimes very difficult.

Basically, for every every time we encounter a KB, a kb, or a similar 
string, we have to look up the source for the file containing the string, 
figure out where the string is used (which may be in a completely different 
source file), and what it means (dividing by 1024 or 1024 * 1024 indicates a 
KiB and a MiB, respectively).

How big is this problem? Quite big. Here are just some of the different 
strings used in various official KDE apps (I have not included strings for 
MiB, GiB, etc.):

KB kB kb kBytes kBi kbit

Do you know what all of these means? Always? Do the author (frequently not). 
Do the user?

We have a similar issue when the units are used to measure speed or 
frequency. I have found all of the following in various KDE apps:

kbps Kbps kbs kb/s kB/s KB/s kbits/s kbit/sec kb/sec

Each time I have to look up to see if the author meant a 1000 bytes, 1024 
bytes, 1000 bits, 1024 bits, and then provide the correct translation, e.g., 
KiB/s or kb/s (which both follow the official SI system for derived units, 
where ‘ps’ or ‘/sec’ or ‘/secs’ is never used).

So, I’d ask the KDE developer to *please* clean up this mess.

Follow SI consistently. Preferably also use kibi and mebi units instead kilo 
and mega units (exceptions where decimal units are ‘standard’ is OK).

And if possible, please include comments with each string showing that you 
have done so (example: ‘Note: MiB = 1024 × 1024 bytes’, ‘Note: b = bit’, 
‘Note: B = byte’, ’Note: kb/s = 1000 bits per second’), so we don’t have to 
double-check the source code to ensure the author got it right.

Thanks. 

-- 
Karl Ove Hufthammer






More information about the kde-core-devel mailing list