summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-22 08:27:03 (UTC)
committer zautrix <zautrix>2004-10-22 08:27:03 (UTC)
commite61ce30fc3f2376d8e9caff421495496344a8359 (patch) (side-by-side diff)
treee82f8e5a0ecf3f21d246b0f441502cb8ee0e11a7 /kaddressbook
parenta0cd6749d41390ea832e2acd814fe117bdd39c37 (diff)
downloadkdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.zip
kdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.tar.gz
kdepimpi-e61ce30fc3f2376d8e9caff421495496344a8359.tar.bz2
added translations
Diffstat (limited to 'kaddressbook') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabprefs.cpp74
-rw-r--r--kaddressbook/kabprefs.h3
-rw-r--r--kaddressbook/kaddressbookmain.cpp1
-rw-r--r--kaddressbook/kaddressbookview.cpp1
-rw-r--r--kaddressbook/mainembedded.cpp6
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
@@ -25,6 +25,10 @@
//#include <qstring.h>
//#endif //KAB_EMBEDDED
+#include <qtextstream.h>
+#include <qfile.h>
+#include <stdlib.h>
+#include <libkdepim/kpimglobalprefs.h>
#include <kconfig.h>
#include <klocale.h>
@@ -39,6 +43,8 @@ static KStaticDeleter<KABPrefs> staticDeleter;
KABPrefs::KABPrefs()
: KPimPrefs("kaddressbookrc")
{
+
+ mLocaleDict = 0;
mDetailsFont = QFont("helvetica",12);
KPrefs::setCurrentGroup( "Views" );
addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
@@ -85,6 +91,9 @@ KABPrefs::KABPrefs()
KABPrefs::~KABPrefs()
{
//qDebug("KABPrefs::~KABPrefs() ");
+ setLocaleDict( 0 );
+ if ( mLocaleDict )
+ delete mLocaleDict;
}
KABPrefs *KABPrefs::instance()
@@ -115,6 +124,71 @@ KConfig* KABPrefs::getConfig()
{
return config();
}
+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();
+}
/*US
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 4a3b6e2..1098f4c 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -25,6 +25,7 @@
#define KABPREFS_H
#include <qstringlist.h>
+#include <qdict.h>
#include <libkdepim/kpimprefs.h>
@@ -60,6 +61,7 @@ class KABPrefs : public KPimPrefs
/** Write preferences to config file */
// void usrWriteConfig();
#endif //KAB_EMBEDDED
+ void usrReadConfig();
// GUI
@@ -87,6 +89,7 @@ class KABPrefs : public KPimPrefs
private:
KABPrefs();
+ 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
@@ -47,7 +47,6 @@ KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainW
//MOC_SKIP_END
#endif //KAB_EMBEDDED
{
-
setIcon(SmallIcon( "ka24" ) );
#if 0
//US for embedded systems, create the toolbar before we initiate KABCore.
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index da28870..8062354 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -43,6 +43,7 @@ KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
const char *name )
: QWidget( parent, name ), mAddressBook( ab ), mFieldList()
{
+
initGUI();
}
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 40089a1..a8816f9 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -15,10 +15,11 @@
#include <kglobal.h>
#include <stdio.h>
#include <qdir.h>
+#include "kabprefs.h"
#include "kaddressbookmain.h"
#include "externalapphandler.h"
#include <libkdepim/kpimglobalprefs.h>
-
+void dumpMissing();
int main( int argc, char **argv )
{
#ifndef DESKTOP_VERSION
@@ -71,6 +72,8 @@ int main( int argc, char **argv )
#endif
KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
+ // init language
+ KABPrefs::instance();
KAddressBookMain m ;
//US MainWindow m;
QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
@@ -88,6 +91,7 @@ int main( int argc, char **argv )
#endif
a.exec();
+ dumpMissing();
}
qDebug("KA: Bye! ");