-rw-r--r-- | microkde/kdecore/klocale.cpp | 60 |
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 @@ -1,83 +1,133 @@ #include <qregexp.h> #include <qapplication.h> #include "kdebug.h" #include "kcalendarsystemgregorian.h" #include "klocale.h" #include <qstringlist.h> -QStringList missingTrans; + +//#define COLLECT_TRANSLATION + QDict<QString> *mLocaleDict = 0; 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 ; } QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); int i; for ( i = 0; i< missingTrans.count(); ++i ) { QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; } 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); } } + } } QString i18n(const char *,const char *text) { return i18n( text ); } QString i18n(const char *text1, const char *textn, int num) { if ( num == 1 ) return i18n( text1 ); else { |