Bug 95437 - Translation of tips does not work
Summary: Translation of tips does not work
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Usability-i18n (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
: 98408 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-12-19 08:22 UTC by stefan.asserhall
Modified: 2021-12-30 15:50 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.5.0


Attachments
Patch to fix translation of tips (5.95 KB, patch)
2005-01-19 19:14 UTC, stefan.asserhall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stefan.asserhall 2004-12-19 08:22:20 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc (GCC) 3.3.3 
OS:                Linux

Translation of (most) tips does not work since ktip.cpp CVS commit 1.44, 
because the code does not exactly match what is done by the script 
preparetips.It would be possible to change the script, but that would 
cause lots of fuzzy translations. Here is a patch that works for me:

Index: kdeui/ktip.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktip.cpp,v
retrieving revision 1.46
diff -u -3 -p -r1.46 ktip.cpp
--- kdeui/ktip.cpp      2 Nov 2004 15:59:02 -0000       1.46
+++ kdeui/ktip.cpp      19 Dec 2004 07:42:30 -0000
@@ -111,7 +111,14 @@ void KTipDatabase::addTips(const QString
     int pos = -1;
     while ((pos = content.find("<html>", pos + 1, false)) != -1)
     {
-       const QString tip = content.mid(pos + 6, content.find("</html>", pos, fa
lse) - pos - 6).stripWhiteSpace();
+       // to make translations work, tip extraction here must exactly
+       // match what is done by the preparetips script
+       QString tip = content
+           .mid(pos, content.find("</html>", pos, false) - pos)
+           .stripWhiteSpace()
+           .mid(6) + "\n";
+       if (tip.startsWith("\n"))
+            tip = tip.mid(1);
         if (tip.isEmpty())
         {
             kdDebug() << "Empty tip found! Skipping! " << pos << endl;
Comment 1 Stephan Kulow 2005-01-17 10:02:32 UTC
CVS commit by coolo: 

fixing ktip translations
BUG: 95437


  M +8 -1      ktip.cpp   1.48
  M +3 -0      preparetips   1.7


--- kdelibs/kdeui/ktip.cpp  #1.47:1.48
@@ -113,5 +113,12 @@ void KTipDatabase::addTips(const QString
     while ((pos = content.find("<html>", pos + 1, false)) != -1)
     {
-        const QString tip = content.mid(pos + 6, content.find("</html>", pos, false) - pos - 6).stripWhiteSpace();
+       // to make translations work, tip extraction here must exactly 
+       // match what is done by the preparetips script 
+       QString tip = content 
+           .mid(pos, content.find("</html>", pos, false) - pos) 
+           .stripWhiteSpace() 
+           .mid(6) + "\n"; 
+       if (tip.startsWith("\n")) 
+            tip = tip.mid(1); 
         if (tip.isEmpty())
         {

--- kdelibs/kdeui/preparetips  #1.6:1.7
@@ -5,4 +5,7 @@
 # 2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
 
+# IMPORTANT NOTE: Do not change the output without checking if
+# translations still work!
+
 sub printText
 {


Comment 2 stefan.asserhall 2005-01-17 18:22:43 UTC
My patch obviously did not cover all cases. Tips with tabs '\t' and empty lines within the tip 'text\n\ntext' are still not handled correctly (see e.g. kdeedu/kstars/kstars/data/tips). I'm working on an improved patch.
Comment 3 stefan.asserhall 2005-01-19 19:14:01 UTC
Created attachment 9178 [details]
Patch to fix translation of tips

Here is a new patch, that I believe really solves the bug.

This patch has been tested and works with all tips files in CVS.
The now unused "kdebase/ktip/preparetips" can be removed from CVS.
The digikam part of the patch also fixes an untranslatable string in the about
dialog.
Comment 4 kstars 2005-02-09 00:58:31 UTC
I believe this bug is causing bug #98408 (untranslated tips in KStars).  So, if you apply Stefan's patch, you'll kill two birds with one stone :)
Comment 5 Stephan Kulow 2005-02-11 14:54:40 UTC
*** Bug 98408 has been marked as a duplicate of this bug. ***
Comment 6 Stephan Kulow 2005-02-11 15:05:23 UTC
I commited all but digikam
Comment 7 Renchi Raju 2005-02-11 18:35:43 UTC
from the digikam side, the later part of the patch has been applied. thanks.
you also referred to an untranslatable string in the about dialog. Which one would that be?
Comment 8 stefan.asserhall 2005-02-11 21:00:26 UTC
The untranslatable string in the about dialog was Description in main.cpp in the patch. I think that strings used as arguments to aboutData must be in English, because of the way KAboutData handles translation. As far as I know, it is not possible to create a string like Description and still be able to translate it, short of creating your own About dialog.
Comment 9 caulier.gilles 2021-12-30 15:50:21 UTC
Fixed with works from bug #438701 for next 7.5.0 release

Gilles Caulier