Re: Full Gettext support in KBabel

Chusslove Illich <[email protected]> Sun, 23 Oct 2005 17:31:58 +0200
Newsgroups gmane.comp.kde.devel.kbabel
Message-ID <[email protected]>
> [: Nicolas Goutte :]
> I think that I have found out what I have not liked to the interface
> patch:

Actually, I wouldn't even regard that one as a serious patch, just a very 
temporary makeshift in case proper GUI element support is not viable in 
the short term (next week). Nevertheless...

> - There is a user-visible message, so it should be translated.

It was in msgid, so I somehow went with the flow :) But having it 
translated is indeed advantageous, as the chance for confusion (someone 
actually translating it) will be smaller.

> - You are using "not" "and" and "or". They are not used in KDE. (Not
> sure why, probably because it is to complex to support them for all
> compilers.)
> So please use ! instead of "not", && instead of "and" and || instead
> of "or".

Check. Habit, forgot to browse the code for that.

> Also for the member function void setText(QStringList texts, bool
> hasctxt = false) would it not be easier to have a QString as second
> parameter to avoid to mess with the plural forms.

Right, makes a lot less changes. That's what happens when I try several 
variants and drop onto one, dragging the direction of thinking from the 
others :)

> I have noticed that with the current KDE context, the context is in
> front of the translated text. I am wondering if we should not prefer a
> solution where the Gettext context would be shown first too. (However
> I do not know exactly how.)

That was my first idea as well, but then we would need another separator 
(perhaps even some text in it again). Also, I don't know how is the diff 
highlighting working, but if it has something to do with positions in 
msgid, appending context to the end shouldn't hurt it.

> Also there are a few little details of the code:
> - please use ++var instead of var++ (as var++ creates a new object and
> is therefore slower).

Yep, trying to get into that habit.

Updated interface patch attached.

-- 
Chusslove Illich (Часлав Илић)

_______________________________________________
kbabel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kbabel
patch_interface.diff (text/x-diff, 2.1 KB)
Index: kbabel/kbabelview.cpp
===================================================================
--- kbabel/kbabelview.cpp	(revision 473386)
+++ kbabel/kbabelview.cpp	(working copy)
@@ -1822,7 +1822,7 @@
        disconnect(msgstrEdit,SIGNAL(textChanged()),this,SLOT(autoRemoveFuzzyStatus()));
    }
 
-   msgidLabel->setText(_catalog->msgid(_currentIndex));
+   msgidLabel->setText(_catalog->msgid(_currentIndex), _catalog->msgctxt(_currentIndex));
    msgidLabel->repaint();
 
    msgstrEdit->setText(_catalog->msgstr(_currentIndex));
Index: kbabel/hidingmsgedit.h
===================================================================
--- kbabel/hidingmsgedit.h	(revision 473386)
+++ kbabel/hidingmsgedit.h	(working copy)
@@ -99,7 +99,7 @@
   // reiplemented to return correct value
   bool hasFocus ();
 public slots: // Public slots
-  void setText(QStringList texts);
+  void setText(QStringList texts, QString msgctxt = "");
   void showSingle();
   void showMultiple();
   void showPlurals( bool on );
Index: kbabel/hidingmsgedit.cpp
===================================================================
--- kbabel/hidingmsgedit.cpp	(revision 473386)
+++ kbabel/hidingmsgedit.cpp	(working copy)
@@ -62,7 +62,7 @@
 HidingMsgEdit::~HidingMsgEdit(){
 }
 
-void HidingMsgEdit::setText(QStringList texts){
+void HidingMsgEdit::setText(QStringList texts, QString msgctxt){
   if( texts.count() == 0 )
   {
       kdWarning() << "HidingMsgEdit::setText with empty text" << endl;
@@ -70,10 +70,13 @@
       showSingle();
       return;
   }
+
+  if (not msgctxt.isEmpty())
+      msgctxt = "\n>>>>> " + i18n("Context inserted by KBabel, do not translate:") + "\n" + msgctxt;
   
   if( texts.count() == 1 )
   {
-      _singleEdit->setText(*texts.at(0));
+      _singleEdit->setText(*texts.at(0) + msgctxt);
       showSingle();
   }
   else
@@ -84,7 +87,7 @@
 	  uint i;
           for( i=0 ; i < _numberOfPlurals && text!= texts.end() ; i++, text++ )
 	  {
-	      static_cast<MsgMultiLineEdit *>(_multipleEdit->page(i))->setText(*text);
+	      static_cast<MsgMultiLineEdit *>(_multipleEdit->page(i))->setText(*text + msgctxt);
 	  }
 	  
 	  // clean the non-initialized ones
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBDW6zwMSGXgigGr3ERAmBhAJ9PTP1I2tJDkwSUClQtO6q3CnHP5gCeNuIh
78rZWCJ5X66/9g31OHD+qCo=
=C3UW
-----END PGP SIGNATURE-----