summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klocale.cpp
Unidiff
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp60
1 files changed, 55 insertions, 5 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index d3b04dc..1da1e99 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -9,3 +9,5 @@
9#include <qstringlist.h> 9#include <qstringlist.h>
10QStringList missingTrans; 10
11//#define COLLECT_TRANSLATION
12
11 13
@@ -17,5 +19,12 @@ void setLocaleDict( QDict<QString> * dict )
17} 19}
20
21#ifdef COLLECT_TRANSLATION
22
23QStringList missingTrans;
24QStringList existingTrans1;
25QStringList existingTrans2;
26
18void addMissing(const char *text) 27void addMissing(const char *text)
19{ 28{
20 return; 29
21 QString mis ( text ); 30 QString mis ( text );
@@ -25,2 +34,13 @@ void addMissing(const char *text)
25} 34}
35void addExist(const char *text,QString trans )
36{
37 //return;
38 QString mis ( text );
39 if ( !existingTrans1.contains( mis ) ) {
40 existingTrans1.append(mis);
41 existingTrans2.append(trans);
42
43 }
44
45}
26 46
@@ -29,6 +49,7 @@ void addMissing(const char *text)
29#include <qtextcodec.h> 49#include <qtextcodec.h>
50#endif
30void dumpMissing() 51void dumpMissing()
31{ 52{
32 return; 53#ifdef COLLECT_TRANSLATION
33 QString fileName = "/tmp/usertrans.txt"; 54 QString fileName = "/tmp/usernewtrans.txt";
34 QFile file( fileName ); 55 QFile file( fileName );
@@ -48,4 +69,23 @@ void dumpMissing()
48 file.close(); 69 file.close();
70 {
71 QString fileName = "/tmp/usertrans.txt";
72 QFile file( fileName );
73 if (!file.open( IO_WriteOnly ) ) {
74 return ;
49} 75}
76 QTextStream ts( &file );
77 ts.setCodec( QTextCodec::codecForName("utf8") );
78
79 int i;
80 for ( i = 0; i< existingTrans1.count(); ++i ) {
50 81
82 QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" );
83 QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" );
84 ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n";
85
86 }
87 file.close();
88 }
89#endif
90}
51QString i18n(const char *text) 91QString i18n(const char *text)
@@ -53,3 +93,5 @@ QString i18n(const char *text)
53 if ( ! mLocaleDict ) { 93 if ( ! mLocaleDict ) {
94#ifdef COLLECT_TRANSLATION
54 addMissing( text ); 95 addMissing( text );
96#endif
55 return QString( text ); 97 return QString( text );
@@ -59,3 +101,5 @@ QString i18n(const char *text)
59 if ( ret == 0 ) { 101 if ( ret == 0 ) {
102#ifdef COLLECT_TRANSLATION
60 addMissing( text ); 103 addMissing( text );
104#endif
61 return QString( text ); 105 return QString( text );
@@ -64,6 +108,11 @@ QString i18n(const char *text)
64 if ( (*ret).isEmpty() ) { 108 if ( (*ret).isEmpty() ) {
109#ifdef COLLECT_TRANSLATION
65 addMissing( text ); 110 addMissing( text );
111#endif
66 return QString( text ); 112 return QString( text );
67 } 113 }
68 else 114 else {
115#ifdef COLLECT_TRANSLATION
116 addExist( text, *ret );
117#endif
69 return (*ret); 118 return (*ret);
@@ -71,2 +120,3 @@ QString i18n(const char *text)
71 } 120 }
121 }
72 122