[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How to configure konqueror to show KB and MB instead of KiB and
From:       Michael Pyne <mpyne () kde ! org>
Date:       2009-07-01 1:01:24
Message-ID: 200906302101.31692.mpyne () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


On Tuesday 30 June 2009 18:42:28 Michael Pyne wrote:
> On Tuesday 30 June 2009 09:58:50 Stefan Majewsky wrote:
> > Am Dienstag 30 Juni 2009 14:20:58 schrieb Allan Sandfeld Jensen:
> > > I doubt it! Most people like to the interface to talk a language they
> > > understand. Only technical experts knows what a KiB or a MiB is, most
> > > users on the other hand are comfortable with KB and MBs.
> >
> > But continuing with fuzzy language cannot be an option, either. With KB
> > and MB used for both binary and decimal units, users are confused about
> > things like 500 GB harddrives magically shrinking to 465,6 GB because the
> > latter one is 465,6 GiB. Consistent naming of the units brings more
> > transparency in the end, and frankly, I doubt that anyone really notices
> > the "i" if he does not know about that.
>
> It's not fuzzy.  Everyone knew what MB, KB, etc. meant with regards to
> computers, otherwise they wouldn't have been the units used for decades.

And since this has been bugging me since 4.0 came out, I finally decided to 
take time out to hack together a fix (attached).

With the patch, you should be able to add "HistoricalBinaryUnits=true" to your 
$KDEHOME/share/config/kdeglobals and applications which start up afterwards 
should use KB/MB/etc. instead of KiB/MiB/etc.

If there's interest I'll forward to kde-core-devel for evaluation as well.

Regards,
 - Michael Pyne

["0001-klocale-use-si-binary.patch" (text/x-patch)]

Index: kdecore/localization/klocale.cpp
===================================================================
--- kdecore/localization/klocale.cpp	(revision 988903)
+++ kdecore/localization/klocale.cpp	(working copy)
@@ -228,6 +228,7 @@
   int workingWeekEndDay;
   int weekDayOfPray;
   KLocale::DigitSet dateTimeDigitSet;
+  bool historicalBinaryUnits; // See IEC 60027-2 i.e. kibibyte, mebibyte, etc.
 
   // FIXME: Temporary until full language-sensitivity implemented.
   bool languageSensitiveDigits;
@@ -443,6 +444,8 @@
   readConfigEntry("PositiveSign", "", positiveSign);
   readConfigEntry("NegativeSign", "-", negativeSign);
 
+  readConfigEntry("HistoricalBinaryUnits", false, historicalBinaryUnits);
+
   readConfigNumEntry("DigitSet", KLocale::ArabicDigits,
                      digitSet, KLocale::DigitSet);
   // FIXME: Temporary until full language-sensitivity implemented.
@@ -1354,27 +1357,43 @@
     //Mebi-byte             MiB             2^20    1,048,576 bytes
     //Kibi-byte             KiB             2^10    1,024 bytes
 
+    KLocalizedString TiB(ki18n("%1 TiB"));
+    KLocalizedString GiB(ki18n("%1 GiB"));
+    KLocalizedString MiB(ki18n("%1 MiB"));
+    KLocalizedString KiB(ki18n("%1 KiB"));
+
+    // If using historic prefixes, convert units.
+    // If we were to be doing this often, it may pay to cache the user
+    // preference
+    if (d->historicalBinaryUnits) {
+        TiB = ki18n("%1 TB");
+        GiB = ki18n("%1 GB");
+        MiB = ki18n("%1 MB");
+        KiB = ki18n("%1 KB");
+    }
+
     QString s;
+
     // Gibi-byte
     if ( size >= 1073741824.0 )
     {
         size /= 1073741824.0;
         if ( size > 1024 ) // Tebi-byte
-            s = i18n( "%1 TiB", formatNumber(size / 1024.0, 1));
+            s = TiB.subs( formatNumber(size / 1024.0, 1) ).toString();
         else
-            s = i18n( "%1 GiB", formatNumber(size, 1));
+            s = GiB.subs( formatNumber(size, 1) ).toString();
     }
     // Mebi-byte
     else if ( size >= 1048576.0 )
     {
         size /= 1048576.0;
-        s = i18n( "%1 MiB", formatNumber(size, 1));
+        s = MiB.subs( formatNumber(size, 1) ).toString();
     }
     // Kibi-byte
     else if ( size >= 1024.0 )
     {
         size /= 1024.0;
-        s = i18n( "%1 KiB", formatNumber(size, 1));
+        s = KiB.subs( formatNumber(size, 1) ).toString();
     }
     // Just byte
     else if ( size > 0 )

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic