summaryrefslogtreecommitdiffabout
path: root/microkde/kdecore/klocale.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdecore/klocale.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 3674f28..21e6937 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -1,75 +1,115 @@
#include <qregexp.h>
#include <qapplication.h>
#include "kdebug.h"
#include "kcalendarsystemgregorian.h"
#include "klocale.h"
+#include <qstringlist.h>
+QStringList missingTrans;
QDict<QString> *mLocaleDict = 0;
void setLocaleDict( QDict<QString> * dict )
{
mLocaleDict = dict;
}
+void addMissing(const char *text)
+{
+ return;
+ QString mis ( text );
+ if ( !missingTrans.contains( mis ) )
+ missingTrans.append(mis);
+
+}
+
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qtextcodec.h>
+void dumpMissing()
+{
+ return;
+ 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< missingTrans.count(); ++i ) {
+
+ QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" );
+ ts << "{ \""<<text<< "\",\""<< text <<"\" },\n";
+
+ }
+ file.close();
+}
+
QString i18n(const char *text)
{
- if ( ! mLocaleDict )
+ if ( ! mLocaleDict ) {
+ addMissing( text );
return QString( text );
+ }
else {
QString* ret = mLocaleDict->find(QString(text)) ;
if ( ret == 0 ) {
+ addMissing( text );
return QString( text );
}
else {
- if ( (*ret).isEmpty() )
+ if ( (*ret).isEmpty() ) {
+ addMissing( text );
return QString( text );
+ }
else
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 {
QString text = i18n( textn );
int pos = text.find( "%n" );
if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) );
return text;
}
}
inline void put_it_in( QChar *buffer, uint& index, const QString &s )
{
for ( uint l = 0; l < s.length(); l++ )
buffer[index++] = s.at( l );
}
inline void put_it_in( QChar *buffer, uint& index, int number )
{
buffer[index++] = number / 10 + '0';
buffer[index++] = number % 10 + '0';
}
static int readInt(const QString &str, uint &pos)
{
if (!str.at(pos).isDigit()) return -1;
int result = 0;
for (; str.length() > pos && str.at(pos).isDigit(); pos++)
{
result *= 10;
result += str.at(pos).digitValue();
}
return result;
}