summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
authorzautrix <zautrix>2004-10-23 22:58:21 (UTC)
committer zautrix <zautrix>2004-10-23 22:58:21 (UTC)
commitfcea043d2200bb4bb0b1146a69204af15fb58a7d (patch) (side-by-side diff)
treec2c210290c02f20af3b307f4c4e47ba8915f7a05 /microkde/kdecore
parent22c26311ca936fa1036e406c86e0178c16acd090 (diff)
downloadkdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.zip
kdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.tar.gz
kdepimpi-fcea043d2200bb4bb0b1146a69204af15fb58a7d.tar.bz2
kopimail translation
Diffstat (limited to 'microkde/kdecore') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp62
1 files changed, 56 insertions, 6 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
@@ -7,7 +7,9 @@
#include "klocale.h"
#include <qstringlist.h>
-QStringList missingTrans;
+
+//#define COLLECT_TRANSLATION
+
QDict<QString> *mLocaleDict = 0;
void setLocaleDict( QDict<QString> * dict )
@@ -15,22 +17,41 @@ void setLocaleDict( QDict<QString> * dict )
mLocaleDict = dict;
}
+
+#ifdef COLLECT_TRANSLATION
+
+QStringList missingTrans;
+QStringList existingTrans1;
+QStringList existingTrans2;
+
void addMissing(const char *text)
{
- return;
+
QString mis ( text );
if ( !missingTrans.contains( mis ) )
missingTrans.append(mis);
}
+void addExist(const char *text,QString trans )
+{
+ //return;
+ QString mis ( text );
+ if ( !existingTrans1.contains( mis ) ) {
+ existingTrans1.append(mis);
+ existingTrans2.append(trans);
+
+ }
+
+}
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
+#endif
void dumpMissing()
{
- return;
- QString fileName = "/tmp/usertrans.txt";
+#ifdef COLLECT_TRANSLATION
+ QString fileName = "/tmp/usernewtrans.txt";
QFile file( fileName );
if (!file.open( IO_WriteOnly ) ) {
return ;
@@ -46,27 +67,56 @@ void dumpMissing()
}
file.close();
-}
+ {
+ QString fileName = "/tmp/usertrans.txt";
+ QFile file( fileName );
+ if (!file.open( IO_WriteOnly ) ) {
+ return ;
+ }
+ QTextStream ts( &file );
+ ts.setCodec( QTextCodec::codecForName("utf8") );
+
+ int i;
+ for ( i = 0; i< existingTrans1.count(); ++i ) {
+
+ QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" );
+ QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" );
+ ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n";
+ }
+ file.close();
+ }
+#endif
+}
QString i18n(const char *text)
{
if ( ! mLocaleDict ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
}
else {
QString* ret = mLocaleDict->find(QString(text)) ;
if ( ret == 0 ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
}
else {
if ( (*ret).isEmpty() ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
}
- else
+ else {
+#ifdef COLLECT_TRANSLATION
+ addExist( text, *ret );
+#endif
return (*ret);
+ }
}
}