Bug 136788 - kbabel unable to handle charset changing
Summary: kbabel unable to handle charset changing
Status: RESOLVED WORKSFORME
Alias: None
Product: kbabel
Classification: Miscellaneous
Component: general (show other bugs)
Version: 1.11.4
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Stanislav Visnovsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-03 19:42 UTC by
Modified: 2006-11-15 22:09 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 2006-11-03 19:42:49 UTC
Version:           1.11.4 (using KDE 3.5.5, compiled sources)
Compiler:          Target: x86_64-mandriva-linux-gnu
OS:                Linux (x86_64) release 2.6.17-5mdv

kbabel isnt able to save a file in utf-8, for example a file that is with charset iso-8859-15.

When opening a .po file that is in iso-8859-15, kbabel shoud save it in Utf-8 like is set in the kbabel configuration window in "save" tab, but what happens is that the file is again saved in iso-8859-15.
So to kbabel really save the file in utf-8 the header must be edited and change the line:

Content-Type: text/plain; charset=ISO-8859-15\n

to:

Content-Type: text/plain; charset=UTF-8\n


Now another problem, if i remove all the lines that are in the below field of "Editor header" windows, and then click in button "Apply Definitions", so that all info is regenerated, kbabel puts all lines again but except the line for charset -> Content-Type: text/plain; charset=UTF-8\n

so when saving the .po file appears an error windows saying:

The 'msgfmt' detected a sintace error.
Result of "msgfmt --statistics":
Please, edit the file again.
Result of "msgfmt --statistics:
msgfmt: /home/ze/tmp/kvirc.po: warning: Charset missing in header-
Message conversion to uses's charset will not work.
msgfmt: /home/ze/tmp/kvirc.po: headerfield `Content-Type:' missing in header
msgfmt: found 1 fatal eror

So in this bug report im actually reporting 2 kbabel bugs:
1)unable to save files in utf-8 format (when the file charset is different from utf-8, so isnt able to convert it)

2) When editing header and after clicking in the button "Apply Definitions", doesnt put the line for charset information

Also kbabel only recognizes the charset info of a file through the charset line (Content-Type: text/plain; charset=UTF-8\n), when is should be able to recognize the file by his conteud like it happens with kate or kwrite.
Maybe kbabel should have an option like kate have that shows all charsets and can put the file in those different charsets and save it.
Comment 1 Stephan Johach 2006-11-08 18:16:28 UTC
I am trying to reproduce this behaviour but without success. Can you please 
send your

a) project file 

and 

b) one of the iso-8859-15 coded po-files 

as an attachment to this bug report?
Comment 2 Stephan Johach 2006-11-15 17:31:00 UTC
SVN commit 605159 by johach:

Leave the for loop if the header line is found.
Restore missing Content-Type header information.
This is part 2 of BR 136788.
CCBUG:136788


 M  +15 -3     catalog.cpp  


--- branches/KDE/3.5/kdesdk/kbabel/common/catalog.cpp #605158:605159
@@ -345,6 +345,7 @@
          {
             (*it) = temp;
             found=true;
+            break;
          }
        }
        if(!found)
@@ -364,6 +365,7 @@
          {
             (*it) = temp;
             found=true;
+            break;
          }
        }
        if(!found)
@@ -384,6 +386,7 @@
          {
             (*it) = temp;
             found=true;
+            break;
          }
        }
        if(!found)
@@ -407,6 +410,7 @@
          {
             (*it) = temp;
             found=true;
+            break;
          }
        }
        if(!found)
@@ -416,6 +420,7 @@
    }
     if(!usePrefs || saveOptions.updateCharset)
     {
+        
         found=false;
     
         QString encodingStr;
@@ -427,6 +432,9 @@
         {
             encodingStr=charsetString(saveOptions.encoding);
         }
+
+        temp = "Content-Type: text/plain; charset=" + encodingStr + "\\n";
+                
         it = headerList.begin();
         while( it != headerList.end() )
         {
@@ -477,6 +485,7 @@
          {
             (*it) = temp;
             found=true;
+            break;
          }
        }
        if(!found)
@@ -495,6 +504,7 @@
       {
          (*it) = temp;
          found=true;
+         break;
       }
     }
     if(!found)
@@ -511,6 +521,7 @@
     	{
          (*it) = temp;
          found=true;
+         break;
     	}
    }
    if( !found )
@@ -532,6 +543,7 @@
     	    {
         	(*it) = temp;
         	found=true;
+                break;
     	    }
 	}
         if( !found )
@@ -601,7 +613,7 @@
         QRegExp regexp ( regexpstr );
 
         // The buggy variants exist in English too (of a time before KBabel got a translation for the corresponding language)
-        QRegExp regexpUntranslated ( "^#\\s+translation of .* to .*\\s*$" );
+        QRegExp regexpUntranslated ( "^#\\s+Translation of .* into .*\\s*$" );
 
         kdDebug () << "Temp is '" << temp << "'" << endl;
 
@@ -2486,7 +2498,7 @@
 	bool success = false; // true, when string found
 	bool endReached=false;
 
-	kdDebug(KBABEL) << "findNext active" << endl;
+       kdDebug(KBABEL) << "findNext active" << endl;
 	d->_active=true;
 	d->_stop=false;
 	connect( this, SIGNAL( signalStopActivity() ), this, SLOT( stopInternal() ));
@@ -2564,7 +2576,7 @@
         if(findOpts->ignoreContextInfo)
         {
             contextInfoPos = miscOptions.contextInfo.search(targetStr);
-	    contextInfoLength = miscOptions.contextInfo.matchedLength();
+            contextInfoLength = miscOptions.contextInfo.matchedLength();
             if(contextInfoPos >= 0)
             {
                 targetStr.remove(contextInfoPos,contextInfoLength);
Comment 3 2006-11-15 22:09:08 UTC
fixed