summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore
Side-by-side diff
Diffstat (limited to 'microkde/kdecore') (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 @@
#include <qstringlist.h>
-QStringList missingTrans;
+
+//#define COLLECT_TRANSLATION
+
@@ -17,5 +19,12 @@ void setLocaleDict( QDict<QString> * dict )
}
+
+#ifdef COLLECT_TRANSLATION
+
+QStringList missingTrans;
+QStringList existingTrans1;
+QStringList existingTrans2;
+
void addMissing(const char *text)
{
- return;
+
QString mis ( text );
@@ -25,2 +34,13 @@ void addMissing(const char *text)
}
+void addExist(const char *text,QString trans )
+{
+ //return;
+ QString mis ( text );
+ if ( !existingTrans1.contains( mis ) ) {
+ existingTrans1.append(mis);
+ existingTrans2.append(trans);
+
+ }
+
+}
@@ -29,6 +49,7 @@ void addMissing(const char *text)
#include <qtextcodec.h>
+#endif
void dumpMissing()
{
- return;
- QString fileName = "/tmp/usertrans.txt";
+#ifdef COLLECT_TRANSLATION
+ QString fileName = "/tmp/usernewtrans.txt";
QFile file( fileName );
@@ -48,4 +69,23 @@ 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)
@@ -53,3 +93,5 @@ QString i18n(const char *text)
if ( ! mLocaleDict ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
@@ -59,3 +101,5 @@ QString i18n(const char *text)
if ( ret == 0 ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
@@ -64,6 +108,11 @@ QString i18n(const char *text)
if ( (*ret).isEmpty() ) {
+#ifdef COLLECT_TRANSLATION
addMissing( text );
+#endif
return QString( text );
}
- else
+ else {
+#ifdef COLLECT_TRANSLATION
+ addExist( text, *ret );
+#endif
return (*ret);
@@ -71,2 +120,3 @@ QString i18n(const char *text)
}
+ }