Bug 145477 - Non-translatable strings due to string composition
Summary: Non-translatable strings due to string composition
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: i18n (show other bugs)
Version: 1.4.0
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-16 00:12 UTC by Christian Spitzlay
Modified: 2007-05-25 00:12 UTC (History)
0 users

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 Christian Spitzlay 2007-05-16 00:12:34 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Debian testing/unstable Packages
OS:                Linux

Working on the GUI translations of kst 1.4 I identified some problems with the i18n. 
They stem from the fact that in some places strings are created by replacing 
arguments with other strings. 

The dynamically created string is passed to the i18n function at runtime 
but the message ID extraction that works on the static code has never 
gotten to see any of the composed strings so they cannot be translated.

The examples I found: 

1.)  Please see src/libkstapp/ksteditviewobjectdialog_i.cpp:

void KstEditViewObjectDialogI::showEditViewObjectDialog(KstViewObjectPtr viewObject, KstTopLevelViewPtr top) {
  _viewObject = viewObject;
  if (_viewObject) {
    _viewObject->setDialogLock(true);
  }
  _top = top;
  updateWidgets();
  if (_viewObject) {
    setCaption(i18n("Edit %1").arg(_viewObject->type()));
  }
  _apply->setEnabled(false);
  show();
  raise();
}


And src/libkstapp/kstdatadialog.ui.h:    

setCaption(i18n("New %1").arg(objectName()));


These setCaption calls have two problems: 

First, the results of the calls to type() and objectName() 
are not translated, and second, even if they were, 
this construction kit for strings does not work for all languages / all cases. 
The translation of "New" and "Edit" may depend on the actual second term 
(e.g. its grammatical gender).  

For example: 
"New Equation" should be translated as "Neue Gleichung", 
but "New Plot" should be "Neuer Plot", with an added "r" due to the 
grammatical gender of "Plot".  

Even if I try to circumvent the grammatical problem by chosing a neutral construct
(which may not even be possible in all languages / all cases)
I end up with a mixture of German and English, e.g. "Neu: Equation" 
That's because "Equation" is not translated.

This string appears quite prominently in the window title of the 
"New equation" dialog.


One solution I could think of would be to list all possible string 
combinations as dummy strings so that the message ID extraction gets to see them.  
That would solve both issues, I guess.


(I had talked to George Staikos about this issue but it was already too late for 1.4. 
George suggested I file this as a bug to be fixed later.)
Comment 1 Andrew Walker 2007-05-17 00:50:58 UTC
SVN commit 665440 by arwalker:

BUG:145477 List new and edit strings of objects explicitly to avoid problems in translation

 M  +2 -1      kstcsddialog_i.h  
 M  +2 -1      kstcurvedialog_i.h  
 M  +2 -1      kstdatadialog.ui  
 M  +9 -3      kstdatadialog.ui.h  
 M  +1 -1      ksteditviewobjectdialog_i.cpp  
 M  +2 -1      ksteqdialog_i.h  
 M  +2 -1      ksteventmonitor_i.h  
 M  +2 -1      ksthsdialog_i.h  
 M  +2 -1      kstimagedialog_i.h  
 M  +2 -1      kstmatrixdialog_i.h  
 M  +2 -1      kstpsddialog_i.h  
 M  +2 -1      kstvectordialog_i.h  
 M  +2 -0      kstviewarrow.cpp  
 M  +2 -0      kstviewbox.cpp  
 M  +2 -0      kstviewellipse.cpp  
 M  +2 -0      kstviewlabel.cpp  
 M  +2 -0      kstviewline.cpp  
 M  +4 -0      kstviewobject.cpp  
 M  +2 -0      kstviewobject.h  
 M  +2 -0      kstviewpicture.cpp  
 M  +2 -1      kstvvdialog_i.h  


--- branches/work/kst/1.5/kst/src/libkstapp/kstcsddialog_i.h #665439:665440
@@ -33,7 +33,8 @@
     KST_EXPORT static KstCsdDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Spectrogram"); }
+    QString editTitle() { return tr("Edit Spectrogram"); }
+    QString newTitle() { return tr("New Spectrogram"); }
  
   public slots:
     /** update the entries in the psd dialog to represent current psds */
--- branches/work/kst/1.5/kst/src/libkstapp/kstcurvedialog_i.h #665439:665440
@@ -33,7 +33,8 @@
     KST_EXPORT static KstCurveDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Curve"); }
+    QString editTitle() { return tr("Edit Curve"); }
+    QString newTitle() { return tr("New Curve"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/kstdatadialog.ui #665439:665440
@@ -219,7 +219,8 @@
     <slot>toggleEditMultiple()</slot>
 </slots>
 <functions>
-    <function access="protected" returnType="QString">objectName()</function>
+    <function access="protected" returnType="QString">editTitle()</function>
+    <function access="protected" returnType="QString">newTitle()</function>
     <function access="protected">fillFieldsForEdit()</function>
     <function access="protected">fillFieldsForNew()</function>
     <function access="protected" returnType="KstObjectPtr">findObject( const QString &amp; name )</function>
--- branches/work/kst/1.5/kst/src/libkstapp/kstdatadialog.ui.h #665439:665440
@@ -88,7 +88,7 @@
     _tagName->setEnabled(true);
     _legendText->setEnabled(true);
 
-    setCaption(i18n("New %1").arg(objectName()));
+    setCaption(newTitle());
     QDialog::show();
     raise();
     _ok->setEnabled(true);
@@ -119,7 +119,7 @@
     update();
     fillFieldsForEdit();
 
-    setCaption(i18n("Edit %1").arg(objectName()));
+    setCaption(editTitle());
     QDialog::show();
     raise();
     _ok->setEnabled(true);
@@ -127,12 +127,18 @@
 }
 
 
-QString KstDataDialog::objectName()
+QString KstDataDialog::editTitle()
 {
     return QString::null;
 }
 
 
+QString KstDataDialog::newTitle()
+{
+    return QString::null;
+}
+
+
 void KstDataDialog::fillFieldsForEdit()
 {
 }
--- branches/work/kst/1.5/kst/src/libkstapp/ksteditviewobjectdialog_i.cpp #665439:665440
@@ -80,7 +80,7 @@
   _top = top;
   updateWidgets();
   if (_viewObject) {
-    setCaption(i18n("Edit %1").arg(_viewObject->type()));
+    setCaption(_viewObject->editTitle());
   }
   _apply->setEnabled(false);
   show();
--- branches/work/kst/1.5/kst/src/libkstapp/ksteqdialog_i.h #665439:665440
@@ -33,7 +33,8 @@
     static KstEqDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Equation"); }
+    QString editTitle() { return tr("Edit Equation"); }
+    QString newTitle() { return tr("New Equation"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/ksteventmonitor_i.h #665439:665440
@@ -31,7 +31,8 @@
     static KstEventMonitorI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Event Monitor"); }
+    QString editTitle() { return tr("Edit Event Monitor"); }
+    QString newTitle() { return tr("New Event Monitor"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/ksthsdialog_i.h #665439:665440
@@ -33,7 +33,8 @@
     static KstHsDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Histogram"); }
+    QString editTitle() { return tr("Edit Histogram"); }
+    QString newTitle() { return tr("New Histogram"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/kstimagedialog_i.h #665439:665440
@@ -33,7 +33,8 @@
     static KstImageDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Image"); }
+    QString editTitle() { return tr("Edit Image"); }
+    QString newTitle() { return tr("New Image"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/kstmatrixdialog_i.h #665439:665440
@@ -34,7 +34,8 @@
     static KstMatrixDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Matrix"); }
+    QString editTitle() { return tr("Edit Matrix"); }
+    QString newTitle() { return tr("New Matrix"); }
  
   public slots:
     void update();
--- branches/work/kst/1.5/kst/src/libkstapp/kstpsddialog_i.h #665439:665440
@@ -34,7 +34,8 @@
     KST_EXPORT static KstPsdDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Spectrum"); }
+    QString editTitle() { return tr("Edit Spectrum"); }
+    QString newTitle() { return tr("New Spectrum"); }
  
   public slots:
     /** update the entries in the psd dialog to represent current psds */
--- branches/work/kst/1.5/kst/src/libkstapp/kstvectordialog_i.h #665439:665440
@@ -32,7 +32,8 @@
     static KstVectorDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Vector"); }
+    QString editTitle() { return tr("Edit Vector"); }
+    QString newTitle() { return tr("New Vector"); }
  
   public slots:
     bool newObject();
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewarrow.cpp #665439:665440
@@ -31,6 +31,7 @@
 
 KstViewArrow::KstViewArrow()
 : KstViewLine("Arrow") {
+  _editTitle = i18n("Edit Arrow");
   _hasFromArrow = false;
   _hasToArrow = true;
   _fromArrowScaling = 1.0;
@@ -58,6 +59,7 @@
   
   // always has this value
   _type = "Arrow";
+  _editTitle = i18n("Edit Arrow");
   _standardActions |= Delete | Edit;
 }
 
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewbox.cpp #665439:665440
@@ -31,6 +31,7 @@
 
 KstViewBox::KstViewBox()
 : KstViewObject("Box"), _borderColor(QColor(0, 0, 0)), _borderWidth(0) {
+  _editTitle = i18n("Edit Box");
   _xRound = 0;
   _yRound = 0;
   _cornerStyle = Qt::MiterJoin;
@@ -58,6 +59,7 @@
   
   // these always have these values
   _type = "Box";
+  _editTitle = i18n("Edit Box");
   _standardActions |= Delete | Edit;
   _layoutActions |= Delete | Raise | Lower | RaiseToTop | LowerToBottom | Rename | MoveTo | Copy | CopyTo;
   _fallThroughTransparency = false;
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewellipse.cpp #665439:665440
@@ -28,6 +28,7 @@
 
 KstViewEllipse::KstViewEllipse()
 : KstViewObject("Ellipse"), _borderWidth(1) {
+  _editTitle = i18n("Edit Ellipse");
   setTransparent(true);
   _transparentFill = false;
   _standardActions |= Delete | Edit;
@@ -50,6 +51,7 @@
   
   // always have these values
   _type = "Ellipse";
+  _editTitle = i18n("Edit Ellipse");
   setTransparent(true);
   _standardActions |= Delete | Edit;
   _layoutActions |= Delete | Raise | Lower | RaiseToTop | LowerToBottom | Rename | MoveTo | Copy | CopyTo;
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewlabel.cpp #665439:665440
@@ -72,6 +72,7 @@
   _parsed = 0L;
   _labelMargin = 0;
   _isResizable = false;
+  _editTitle = i18n("Edit Label");
   reparse();
   computeTextSize(_parsed);
 }
@@ -83,6 +84,7 @@
   _fallThroughTransparency = false;
   _container = false;
   _type = "Label";
+  _editTitle = i18n("Edit Label");
   _dataPrecision = 8;
   _interpret = true;
   _replace = true;
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewline.cpp #665439:665440
@@ -30,6 +30,7 @@
 
 KstViewLine::KstViewLine(const QString& type)
 : KstViewObject(type), _width(0) {
+  _editTitle = i18n("Edit Line");
   setTransparent(true);
   _container = false;
   _capStyle = Qt::FlatCap; 
@@ -77,6 +78,7 @@
   // always these values
   setTransparent(true);
   _type = "Line";
+  _editTitle = i18n("Edit Line");
   setMinimumSize(QSize(1, 1));
   _standardActions |= Delete | Edit;
 }
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewobject.cpp #665439:665440
@@ -1824,6 +1824,10 @@
 }
 
 
+const QString& KstViewObject::editTitle() const {
+  return _editTitle;
+}
+
 void KstViewObject::setMinimumSize(const QSize& sz) {
   _minimumSize = sz.expandedTo(QSize(1, 1)); // 1,1 is the absolute minimum
 }
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewobject.h #665439:665440
@@ -204,6 +204,7 @@
     virtual void detach(); // remove from its parent
 
     const QString& type() const;
+    const QString& editTitle() const;
 
     virtual bool mouseHandler() const;
     virtual void mouseMoveEvent(QWidget *view, QMouseEvent *e);
@@ -323,6 +324,7 @@
     QSize _idealSize; //ideal size for object. useful when _maintainAspect==true
     KstAspectRatio _aspectOldZoomedObject;
     QString _type;
+    QString _editTitle;
     QRegion _clipMask; // The mask of this object
     QMap<int, QString> _moveToMap;
     QMap<int, QString> _copyToMap;
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewpicture.cpp #665439:665440
@@ -37,6 +37,7 @@
 
 KstViewPicture::KstViewPicture()
 : KstBorderedViewObject("Picture") {
+  _editTitle = i18n("Edit Picture");
   _refresh = 0;
   _timer = 0L;
   setTransparent(true);
@@ -63,6 +64,7 @@
 
   // always have these values
   _type = "Picture";
+  _editTitle = i18n("Edit Picture");
   setTransparent(true);
   _standardActions |= Delete | Edit;
 }
--- branches/work/kst/1.5/kst/src/libkstapp/kstvvdialog_i.h #665439:665440
@@ -32,7 +32,8 @@
     static KstVvDialogI *globalInstance();
 
   protected:
-    QString objectName() { return tr("Vector View"); }
+    QString editTitle() { return tr("Edit Vector View"); }
+    QString newTitle() { return tr("New Vector View"); }
  
   public slots:
     void update();
Comment 2 Christian Spitzlay 2007-05-25 00:12:10 UTC
Wow, that was quick.  :)
Thanks.