summaryrefslogtreecommitdiff
path: root/library
Side-by-side diff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp55
-rw-r--r--library/qpeapplication.cpp40
2 files changed, 60 insertions, 35 deletions
diff --git a/library/global.cpp b/library/global.cpp
index fd7579a..dd15eb7 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -8,24 +8,25 @@
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#define QTOPIA_INTERNAL_LANGLIST
#include <qpe/qpedebug.h>
#include <qpe/global.h>
#include <qpe/qdawg.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/storage.h>
#include <qpe/applnk.h>
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
#include "qpe/qcopenvelope_qws.h"
#endif
#include <qfile.h>
@@ -161,30 +162,36 @@ Global::Global()
words for the current locale.
\sa addedDawg()
*/
const QDawg& Global::fixedDawg()
{
if ( !fixed_dawg ) {
if ( !docDirCreated )
createDocDir();
fixed_dawg = new QDawg;
QString dawgfilename = dictDir() + "/dawg";
- QString lang = getenv( "LANG" );
- QString dawgfilename_lang = dawgfilename + "." + lang;
- QString words_lang = dictDir() + "/words." + lang;
- if ( QFile::exists(dawgfilename_lang) ||
- QFile::exists(words_lang) )
- dawgfilename = dawgfilename_lang;
+ QString words_lang;
+ QStringList langs = Global::languageList();
+ for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
+ QString lang = *it;
+ words_lang = dictDir() + "/words." + lang;
+ QString dawgfilename_lang = dawgfilename + "." + lang;
+ if ( QFile::exists(dawgfilename_lang) ||
+ QFile::exists(words_lang) ) {
+ dawgfilename = dawgfilename_lang;
+ break;
+ }
+ }
QFile dawgfile(dawgfilename);
if ( !dawgfile.exists() ) {
QString fn = dictDir() + "/words";
if ( QFile::exists(words_lang) )
fn = words_lang;
QFile in(fn);
if ( in.open(IO_ReadOnly) ) {
fixed_dawg->createFromWords(&in);
dawgfile.open(IO_WriteOnly);
fixed_dawg->write(&dawgfile);
dawgfile.close();
@@ -630,15 +637,51 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
StorageInfo storage;
const QList<FileSystem> &fs = storage.fileSystems();
QListIterator<FileSystem> it ( fs );
for ( ; it.current(); ++it ) {
if ( (*it)->isRemovable() ) {
QString path = (*it)->path();
DocLnkSet ide( path, mimefilter );
folder->appendFrom(ide);
}
}
}
+QStringList Global::languageList()
+{
+ QString lang = getenv("LANG");
+ QStringList langs;
+ langs.append(lang);
+ int i = lang.find(".");
+ if ( i > 0 )
+ lang = lang.left( i );
+ i = lang.find( "_" );
+ if ( i > 0 )
+ langs.append(lang.left(i));
+ return langs;
+}
+
+QStringList Global::helpPath()
+{
+ QStringList path;
+ QStringList langs = Global::languageList();
+ for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) {
+ QString lang = *it;
+ if ( !lang.isEmpty() )
+ path += QPEApplication::qpeDir() + "/help/" + lang + "/html";
+ }
+ path += QPEApplication::qpeDir() + "/pics";
+ path += QPEApplication::qpeDir() + "/help/en/html";
+ path += QPEApplication::qpeDir() + "/docs";
+ QString dir = QDir::current().canonicalPath();
+ if ( dir == "/" )
+ dir += "/docs";
+ else {
+ path += dir + "/../pics";
+ dir += "/../docs";
+ path += dir;
+ }
+ return path;
+}
#include "global.moc"
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 70ffec1..4dbfbd8 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -10,24 +10,25 @@
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
** $Id$
**
**********************************************************************/
+#define QTOPIA_INTERNAL_LANGLIST
#include <stdlib.h>
#include <unistd.h>
#include <qfile.h>
#ifdef Q_WS_QWS
#ifndef QT_NO_COP
#if QT_VERSION <= 231
#define private public
#define sendLocally processEvent
#include "qcopenvelope_qws.h"
#undef private
#else
#include "qcopenvelope_qws.h"
@@ -128,40 +129,25 @@ public:
{
QCopRec* r;
for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
QCopChannel::sendLocally(r->channel,r->message,r->data);
qcopq.clear();
}
};
class ResourceMimeFactory : public QMimeSourceFactory {
public:
ResourceMimeFactory()
{
- QStringList path;
- QString lang = getenv("LANG");
- if ( !lang.isEmpty() )
- path += QPEApplication::qpeDir() + "/help/" + lang + "/html";
- path += QPEApplication::qpeDir() + "/pics";
- path += QPEApplication::qpeDir() + "/help/en/html";
- path += QPEApplication::qpeDir() + "/docs";
- QString dir = QDir::current().canonicalPath();
- if ( dir == "/" )
- dir += "/docs";
- else {
- path += dir + "/../pics";
- dir += "/../docs";
- path += dir;
- }
- setFilePath( path );
+ setFilePath( Global::helpPath() );
setExtensionType("html","text/html;charset=UTF-8");
}
const QMimeSource* data(const QString& abs_name) const
{
const QMimeSource* r = QMimeSourceFactory::data(abs_name);
if ( !r ) {
int sl = abs_name.length();
do {
sl = abs_name.findRev('/',sl-1);
QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
int dot = name.findRev('.');
@@ -528,50 +514,46 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
argc-=1;
}
}
/* overide stored arguments */
setArgs(argc, argv);
#endif
qwsSetDecoration( new QPEDecoration() );
#ifndef QT_NO_TRANSLATION
- char *l = getenv( "LANG" );
- QString lang;
- if ( l ) {
- lang = l;
+ QStringList langs = Global::languageList();
+ for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
+ QString lang = *it;
- /*
- Config config("qpe");
- config.setGroup( "Appearance" );
- lang = config.readEntry( "Language", lang );
- */
+ QTranslator * trans;
+ QString tfn;
- QTranslator * trans = new QTranslator(this);
- QString tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
+ trans = new QTranslator(this);
+ tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
if ( trans->load( tfn ))
installTranslator( trans );
else
delete trans;
trans = new QTranslator(this);
- tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
+ tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
if ( trans->load( tfn ))
installTranslator( trans );
else
delete trans;
- //###language/font hack; should look it up somewhere
+ //###language/font hack; should look it up somewhere
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
setFont( fn );
}
}
#endif
applyStyle();
if ( type() == GuiServer ) {
setScreenSaverInterval(-1);
setVolume();