summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp66
1 files changed, 32 insertions, 34 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 0b6d56d..1117240 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -153,13 +153,12 @@ public:
QCString fontFamily;
int fontSize;
int smallIconSize;
int bigIconSize;
- QStringList langs;
QString appName;
struct QCopRec
{
QCopRec( const QCString &ch, const QCString &msg,
const QByteArray &d ) :
channel( ch ), message( msg ), data( d )
@@ -755,12 +754,35 @@ void QPEApplication::processQCopFile()
\sa qcop.html
Note that messages received here may be processed by qpe application
and emitted as signals, such as flush() and reload().
*/
+#ifndef QT_NO_TRANSLATION
+static void qtopia_loadTranslations( const QStringList& qms )
+{
+ QStringList langs = Global::languageList();
+
+ for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
+ QString lang = *it;
+
+ QTranslator * trans;
+ QString tfn;
+
+ for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
+ trans = new QTranslator(qApp);
+ tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
+ if ( trans->load( tfn ))
+ qApp->installTranslator( trans );
+ else
+ delete trans;
+ }
+ }
+}
+#endif
+
/*!
Constructs a QPEApplication just as you would construct
a QApplication, passing \a argc, \a argv, and \a t.
For applications, \a t should be the default, GuiClient. Only
the Qtopia server passes GuiServer.
@@ -849,31 +871,18 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
#endif
#ifdef Q_WS_QWS
/* load the font renderer factories */
FontDatabase::loadRenderers();
#endif
#ifndef QT_NO_TRANSLATION
+ QStringList qms;
+ qms << "libqpe";
+ qms << "libopie";
+ qms << d->appName;
- d->langs = Global::languageList();
- for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
- QString lang = *it;
-
- installTranslation( lang + "/libopie.qm");
- installTranslation( lang + "/libqpe.qm" );
- installTranslation( lang + "/" + d->appName + ".qm" );
-
-
- //###language/font hack; should look it up somewhere
-#ifdef QWS
-
- if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
- QFont fn = FontManager::unicodeFont( FontManager::Proportional );
- setFont( fn );
- }
-#endif
- }
+ qtopia_loadTranslations(qms);
#endif
applyStyle();
if ( type() == GuiServer ) {
setVolume();
@@ -900,12 +909,16 @@ void QPEApplication::initApp( int argc, char **argv )
QCString channel = QCString(argv[0]);
channel.replace(QRegExp(".*/"),"");
d->appName = channel;
+#ifndef QT_NO_TRANSLATION
+ qtopia_loadTranslations( QStringList()<<channel );
+#endif
+
#if QT_VERSION > 235
qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
#endif
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this);
@@ -931,16 +944,12 @@ void QPEApplication::initApp( int argc, char **argv )
argc-=1;
}
}
/* overide stored arguments */
setArgs(argc, argv);
-
- /* install translation here */
- for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
- installTranslation( (*it) + "/" + d->appName + ".qm" );
}
#endif
static QPtrDict<void>* inputMethodDict = 0;
static void createInputMethodDict()
@@ -2176,23 +2185,12 @@ void QPEApplication::tryQuit()
d->store_widget_rect(d->qpe_main_widget, d->appName);
processEvents();
quit();
}
-/*!
- \internal
-*/
-void QPEApplication::installTranslation( const QString& baseName ) {
- QTranslator* trans = new QTranslator(this);
- QString tfn = qpeDir() + "/i18n/"+baseName;
- if ( trans->load( tfn ) )
- installTranslator( trans );
- else
- delete trans;
-}
/*!
\internal
User initiated quit. Makes the window 'Go Away'. If preloaded this means
hiding the window. If not it means quitting the application.
As this is user initiated we don't need to check state.