author | zautrix <zautrix> | 2004-10-22 08:27:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 08:27:03 (UTC) |
commit | e61ce30fc3f2376d8e9caff421495496344a8359 (patch) (side-by-side diff) | |
tree | e82f8e5a0ecf3f21d246b0f441502cb8ee0e11a7 /kaddressbook | |
parent | a0cd6749d41390ea832e2acd814fe117bdd39c37 (diff) | |
download | kdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.zip kdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.tar.gz kdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.tar.bz2 |
added translations
-rw-r--r-- | kaddressbook/kabprefs.cpp | 74 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 6 |
5 files changed, 83 insertions, 2 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 9270a7d..4b3ee47 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -27,2 +27,6 @@ +#include <qtextstream.h> +#include <qfile.h> +#include <stdlib.h> +#include <libkdepim/kpimglobalprefs.h> @@ -41,2 +45,4 @@ KABPrefs::KABPrefs() { + + mLocaleDict = 0; mDetailsFont = QFont("helvetica",12); @@ -87,2 +93,5 @@ KABPrefs::~KABPrefs() //qDebug("KABPrefs::~KABPrefs() "); + setLocaleDict( 0 ); + if ( mLocaleDict ) + delete mLocaleDict; } @@ -117,2 +126,67 @@ KConfig* KABPrefs::getConfig() } +void KABPrefs::usrReadConfig() +{ + QString fileName ; +#ifndef DESKTOP_VERSION + fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; +#else + fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; +#endif + int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; + mLocaleDict = 0; + if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { + + if ( mPreferredLanguage == 1 ) + fileName = fileName+"germantranslation.txt"; + else if ( mPreferredLanguage == 4 ) + fileName = fileName+"usertranslation.txt"; + else if ( mPreferredLanguage == 2 ) + fileName = fileName+"frenchtranslation.txt"; + else if ( mPreferredLanguage == 3 ) + fileName = fileName+"italiantranslation.txt"; + QFile file( fileName ); + if (file.open( IO_ReadOnly ) ) { + QTextStream ts( &file ); + ts.setEncoding( QTextStream::Latin1 ); + //ts.setCodec( QTextCodec::latin1 ); + QString text = ts.read(); + file.close(); + text.replace( QRegExp("\\\\n"), "\n" ); + QString line; + QString we; + QString wt; + int br = 0; + int nbr; + nbr = text.find ( "},", br ); + line = text.mid( br, nbr - br ); + br = nbr+1; + int se, ee, st, et; + mLocaleDict = new QDict<QString>; + QString end = "{ \"\",\"\" }"; + while ( (line != end) && (br > 1) ) { + //qDebug("%d *%s* ", br, line.latin1()); + se = line.find("\"")+1; + et = line.findRev("\"",-1); + ee = line.find("\",\""); + st = ee+3; + we = line.mid( se, ee-se ); + wt = line.mid( st, et-st ); + //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); + mLocaleDict->insert( we, new QString (wt) ); + nbr = text.find ( "}", br ); + line = text.mid( br, nbr - br ); + br = nbr+1; + } + //qDebug("end *%s* ", end.latin1()); + + setLocaleDict( mLocaleDict ); + } else { + qDebug("KO: Cannot find translation file %s",fileName.latin1() ); + } + + + } + qDebug("KABPrefs::usrReadConfig********************** "); + KPimPrefs::usrReadConfig(); +} diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 4a3b6e2..1098f4c 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h @@ -27,2 +27,3 @@ #include <qstringlist.h> +#include <qdict.h> @@ -62,2 +63,3 @@ class KABPrefs : public KPimPrefs #endif //KAB_EMBEDDED + void usrReadConfig(); @@ -89,2 +91,3 @@ class KABPrefs : public KPimPrefs + QDict<QString> *mLocaleDict; static KABPrefs *sInstance; diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index f48f214..2832257 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -49,3 +49,2 @@ KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainW { - setIcon(SmallIcon( "ka24" ) ); diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index da28870..8062354 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp @@ -45,2 +45,3 @@ KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, { + initGUI(); diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 40089a1..a8816f9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -17,2 +17,3 @@ #include <qdir.h> +#include "kabprefs.h" #include "kaddressbookmain.h" @@ -20,3 +21,3 @@ #include <libkdepim/kpimglobalprefs.h> - +void dumpMissing(); int main( int argc, char **argv ) @@ -73,2 +74,4 @@ int main( int argc, char **argv ) KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); + // init language + KABPrefs::instance(); KAddressBookMain m ; @@ -90,2 +93,3 @@ int main( int argc, char **argv ) + dumpMissing(); |