Bug 52640 - text font and i18n() problems
Summary: text font and i18n() problems
Status: RESOLVED FIXED
Alias: None
Product: kcontrol
Classification: Miscellaneous
Component: kcminfo (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Helge Deller
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-05 18:53 UTC by Claudiu Costin
Modified: 2012-08-26 19:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Claudiu Costin 2003-01-05 18:53:10 UTC
Version:            (using KDE KDE 3.0.99)
Installed from:    Compiled From Sources
Compiler:          gcc version 2.95.4 20011002 (Debian prerelease) 
OS:          Linux

1) In "Interupts" module the text from KListView header,
namely "Interupts" is fixed font, instead of KDE default
font (usualy helvetica/arial)

2) In "X Server" information module you reffer to "bit" and "byte",
but there are plural form here. So, you should add
"bit" and "bits" when bit>1 and bit=1. Same for "byte" suffix,
altough I don't indetified yet where byte may be used
as singular form.
Comment 1 Helge Deller 2003-01-06 17:12:52 UTC
Subject: kdebase/kcontrol/info

CVS commit by deller: 

CCMAIL: 52640-done@bugs.kde.org
Fix default font usage of listbox headers, closes bug #52640.


  M +3 -2      info.cpp   1.58


--- kdebase/kcontrol/info/info.cpp  #1.57:1.58
@@ -5,5 +5,5 @@
         (But all functions in THIS FILE should be system independent !)
 
-        (C) 1998-2002 by Helge Deller <deller@kde.org>
+        (C) 1998-2003 by Helge Deller <deller@kde.org>
 
         ** main.cpp includes this file ! **
@@ -355,4 +355,5 @@ void KInfoListWidget::load()
     /* is the user allowed to use sorting ? */
     lBox->header()->setClickEnabled(sorting_allowed);
+    lBox->header()->setFont(KGlobalSettings::generalFont());
     lBox->setShowSortIndicator(sorting_allowed);
 


Comment 2 Helge Deller 2003-01-06 17:18:45 UTC
Subject: KDE_3_1_BRANCH: kdebase/kcontrol/info

CVS commit by deller: 

CCMAIL: 52640@bugs.kde.org
Backport: Fix default font usage of listbox headers, closes bug #52640.


  M +3 -2      info.cpp   1.56.2.1


--- kdebase/kcontrol/info/info.cpp  #1.56:1.56.2.1
@@ -5,5 +5,5 @@
         (But all functions in THIS FILE should be system independent !)
 
-        (C) 1998-2002 by Helge Deller <deller@kde.org>
+        (C) 1998-2003 by Helge Deller <deller@kde.org>
 
         ** main.cpp includes this file ! **
@@ -354,4 +354,5 @@ void KInfoListWidget::load()
     /* is the user allowed to use sorting ? */
     lBox->header()->setClickEnabled(sorting_allowed);
+    lBox->header()->setFont(KGlobalSettings::generalFont());
     lBox->setShowSortIndicator(sorting_allowed);
 


Comment 3 Helge Deller 2003-01-06 17:25:14 UTC
Hi Claudiu, 
 
Thanks for the bug report. 
 
The font-problem (1) should be fixed with the above commits in CVS HEAD and 
in the 3.1 BRANCH. 
 
Regarding (2) I don't agree with you. Looking at the strings I see e.g.: 
Pixmap Format #1	1 BPP, Depth: 1 Bit, scanline_pad: 32" and 
Pixmap Format #5	16 BPP, Depth: 16 Bit, scanline_pad: 32" and 
or 
Maximum Request Size	4 194 300 Byte 
 
IMHO, all of those look ok and "16 Bits" doesn't look more correct than "16 Bit". 
 
Greetings, 
Helge 
Comment 4 Claudiu Costin 2003-01-06 21:26:19 UTC
Subject: Re:  text font and i18n() problems

         Dear Helge,

On Lun 06 Ian 2003 18:25, you wrote:
[snip]
> ------- Additional Comments From deller@kde.org  2003-01-06 17:25 -------
> Hi Claudiu,
>
> Thanks for the bug report.
>
> The font-problem (1) should be fixed with the above commits in CVS HEAD and
> in the 3.1 BRANCH.
>
> Regarding (2) I don't agree with you. Looking at the strings I see e.g.:
> Pixmap Format #1	1 BPP, Depth: 1 Bit, scanline_pad: 32" and
> Pixmap Format #5	16 BPP, Depth: 16 Bit, scanline_pad: 32" and
> or
> Maximum Request Size	4 194 300 Byte
>
> IMHO, all of those look ok and "16 Bits" doesn't look more correct than "16
> Bit".
 
   For English speakers yes. But don't forget we _are_ translating this 
in our languages. See translation:

  English     Romanian
 ----------------------
  1 Bit     = 1 bit
 16 Bit     = 16 bi
Comment 5 Helge Deller 2003-01-06 21:35:12 UTC
OK, I'll fix this in HEAD soon. 
 
Helge 
Comment 6 Helge Deller 2003-01-08 01:26:07 UTC
Subject: kdebase/kcontrol/info

CVS commit by deller: 

CCMAIL: 52640-done@bugs.kde.org
i18n changes: fix singular/plural forms of Bit/Bits & Byte/Bytes,
closes BR 52460


  M +27 -10    info.cpp   1.59


--- kdebase/kcontrol/info/info.cpp  #1.58:1.59
@@ -71,5 +71,5 @@ static bool	sorting_allowed;	/* is sorti
 #define PIXEL_ADD       20      // add x Pixel to multicolumns..
 
-#define HEXDIGITS (sizeof(int)*8/4)     /* 4 Byte = 32 Bit = 8 Hex-Digits */
+#define HEXDIGITS (sizeof(int)*8/4)     /* 4 Bytes = 32 Bits = 8 Hex-Digits */
 
 static QString Value( int val, int numbers=1 )
@@ -222,5 +222,5 @@ static QListViewItem* XServer_fill_scree
 }
 
-QString Order( int order )
+static QString Order( int order )
 {
     if (order==LSBFirst) return i18n("LSBFirst"); else
@@ -229,5 +229,20 @@ QString Order( int order )
 }
 
-bool GetInfo_XServer_Generic( QListView *lBox )
+static QString BitString( unsigned long n )
+{
+    return i18n("1 Bit", "%n Bits", n); // singular & plural form of "%d Bit"
+}
+
+static QString ByteString( unsigned long n )
+{
+    /* explanation in BR #52640 (http://bugs.kde.org/show_bug.cgi?id=52640) */
+    if (n == 1)
+        return i18n("1 Byte"); // singular form: "1 Byte" (yes, it's "1", not "%1"!)
+
+    return i18n("%1 Bytes")  // plural form: "%1 Bytes"
+                .arg(KGlobal::locale()->formatNumber(n,0));
+}
+
+static bool GetInfo_XServer_Generic( QListView *lBox )
 {
     /* Many parts of this source are taken from the X11-program "xdpyinfo" */
@@ -290,8 +305,10 @@ bool GetInfo_XServer_Generic( QListView 
         last->setExpandable(true);
         for (i=0; i<n; i++) {
-            item = new QListViewItem(last, item, i18n("Pixmap Format #%1").arg(i+1),
-                        i18n("%1 BPP, Depth: %2 Bit, scanline_pad: %3").
-                        arg(pmf[i].bits_per_pixel).arg(pmf[i].depth).
-                        arg(pmf[i].scanline_pad));
+            item = new QListViewItem(last, item,
+                        i18n("Pixmap Format #%1").arg(i+1),
+                        i18n("%1 BPP, Depth: %2, Scanline padding: %3")
+                                .arg(pmf[i].bits_per_pixel)
+                                .arg(BitString(pmf[i].depth))
+                                .arg(BitString(pmf[i].scanline_pad)));
         }
         XFree ((char *)pmf);
@@ -301,7 +318,7 @@ bool GetInfo_XServer_Generic( QListView 
     if (!req_size) req_size = XMaxRequestSize(dpy);
     last = new QListViewItem(next, last, i18n("Maximum Request Size"),
-                i18n("%1 Byte").arg(KGlobal::locale()->formatNumber(req_size*4,0)));
+                ByteString(req_size*4));
     last = new QListViewItem(next, last, i18n("Motion Buffer Size"),
-                i18n("%1 Byte").arg(KGlobal::locale()->formatNumber(XDisplayMotionBufferSize(dpy), 0)));
+                ByteString(XDisplayMotionBufferSize(dpy)));
 
     last = item = new QListViewItem(next, last, i18n("Bitmap"));


Comment 7 Alexander Potashev 2010-01-13 21:33:53 UTC
Why not using standard plural forms (like in BitString) in ByteString?

(In reply to comment #6)
> Subject: kdebase/kcontrol/info
> 
> CVS commit by deller: 
> 
> CCMAIL: 52640-done@bugs.kde.org
> i18n changes: fix singular/plural forms of Bit/Bits & Byte/Bytes,
> closes BR 52460
> 
> 
>   M +27 -10    info.cpp   1.59
> 
> 
> --- kdebase/kcontrol/info/info.cpp  #1.58:1.59
> @@ -71,5 +71,5 @@ static bool	sorting_allowed;	/* is sorti
>  #define PIXEL_ADD       20      // add x Pixel to multicolumns..
>  
> -#define HEXDIGITS (sizeof(int)*8/4)     /* 4 Byte = 32 Bit = 8 Hex-Digits */
> +#define HEXDIGITS (sizeof(int)*8/4)     /* 4 Bytes = 32 Bits = 8 Hex-Digits */
>  
>  static QString Value( int val, int numbers=1 )
> @@ -222,5 +222,5 @@ static QListViewItem* XServer_fill_scree
>  }
>  
> -QString Order( int order )
> +static QString Order( int order )
>  {
>      if (order==LSBFirst) return i18n("LSBFirst"); else
> @@ -229,5 +229,20 @@ QString Order( int order )
>  }
>  
> -bool GetInfo_XServer_Generic( QListView *lBox )
> +static QString BitString( unsigned long n )
> +{
> +    return i18n("1 Bit", "%n Bits", n); // singular & plural form of "%d Bit"
> +}
> +
> +static QString ByteString( unsigned long n )
> +{
> +    /* explanation in BR #52640 (http://bugs.kde.org/show_bug.cgi?id=52640) */
> +    if (n == 1)
> +        return i18n("1 Byte"); // singular form: "1 Byte" (yes, it's "1", not "%1"!)
> +
> +    return i18n("%1 Bytes")  // plural form: "%1 Bytes"
> +                .arg(KGlobal::locale()->formatNumber(n,0));
> +}
> +
> +static bool GetInfo_XServer_Generic( QListView *lBox )
>  {
>      /* Many parts of this source are taken from the X11-program "xdpyinfo" */
> @@ -290,8 +305,10 @@ bool GetInfo_XServer_Generic( QListView 
>          last->setExpandable(true);
>          for (i=0; i<n; i++) {
> -            item = new QListViewItem(last, item, i18n("Pixmap Format #%1").arg(i+1),
> -                        i18n("%1 BPP, Depth: %2 Bit, scanline_pad: %3").
> -                        arg(pmf[i].bits_per_pixel).arg(pmf[i].depth).
> -                        arg(pmf[i].scanline_pad));
> +            item = new QListViewItem(last, item,
> +                        i18n("Pixmap Format #%1").arg(i+1),
> +                        i18n("%1 BPP, Depth: %2, Scanline padding: %3")
> +                                .arg(pmf[i].bits_per_pixel)
> +                                .arg(BitString(pmf[i].depth))
> +                                .arg(BitString(pmf[i].scanline_pad)));
>          }
>          XFree ((char *)pmf);
> @@ -301,7 +318,7 @@ bool GetInfo_XServer_Generic( QListView 
>      if (!req_size) req_size = XMaxRequestSize(dpy);
>      last = new QListViewItem(next, last, i18n("Maximum Request Size"),
> -                i18n("%1 Byte").arg(KGlobal::locale()->formatNumber(req_size*4,0)));
> +                ByteString(req_size*4));
>      last = new QListViewItem(next, last, i18n("Motion Buffer Size"),
> -                i18n("%1 Byte").arg(KGlobal::locale()->formatNumber(XDisplayMotionBufferSize(dpy), 0)));
> +                ByteString(XDisplayMotionBufferSize(dpy)));
>  
>      last = item = new QListViewItem(next, last, i18n("Bitmap"));
> 
> 
>
Comment 8 Helge Deller 2010-01-13 21:59:00 UTC
Hi Alexander,

> Why not using standard plural forms (like in BitString) in ByteString?

If in i18n(a,b,c), c needs to be an integer, then arg(KGlobal::locale()->formatNumber(n,0)) won't work (it's a string).
You may test a patch and come up with a solution though, if it works for you.
Comment 9 Alexander Potashev 2010-01-13 22:05:51 UTC
Ok, I understand now.
But why is it necessary to use formatNumber here? (while not using it anywhere in KDE when dealing with numbers of bytes)

(In reply to comment #8)
> Hi Alexander,
> 
> > Why not using standard plural forms (like in BitString) in ByteString?
> 
> If in i18n(a,b,c), c needs to be an integer, then
> arg(KGlobal::locale()->formatNumber(n,0)) won't work (it's a string).
> You may test a patch and come up with a solution though, if it works for you.
Comment 10 Andrius Štikonas 2010-06-03 16:11:29 UTC
This decision to have 2 cases for singular and plural is really strange. How is that supposed to work with languages that have more than 2 plural forms?
Comment 11 Chusslove Illich 2012-08-26 19:59:05 UTC
Git commit 919d62e5119146c27bbf223a6d88cfe91e540923 by Chusslove Illich (Часлав Илић).
Committed on 26/08/2012 at 11:24.
Pushed by ilic into branch 'master'.

i18n functions automatically locale-format numbers.

M  +3    -7    kinfocenter/Modules/base/os_base.h

http://commits.kde.org/kde-workspace/919d62e5119146c27bbf223a6d88cfe91e540923