When I confirm the preferences dialogue, Merkaartor only speaks in
English to me from then on. Before that and after a restart of the
application, it usually speaks in German (my UI default). The problem is
that it won't find my translation files. In MainWindow::updateLanguage()
it only looks in the current directory, but that has oft proven to be in
some distant galaxy. This patch adds the application executable's
directory as a default, like the Qt library's function is the default
for the Qt system language. Additionally, it displays an error message
if a language couldn't be found - and won't change anything (i.e.
install that null pointer language).
Although the new error messages use tr() and I have translated them in
Linguist, they'd always show up in English. Although my other
translation additions already have worked. Not sure why this doesn't.
This patch basically keeps the language setting for my Merkaartor
version, which it wouldn't do alone. This may be specific to my build
procedure though and may not happen in other builds or platforms. But
then again, I believe that it doesn't harm.
--
Yves Goergen "LonelyPixel" <[email protected]>
Visit my web laboratory at http://beta.unclassified.de
--- merkaartor\MainWindow.cpp.orig Fri Jan 02 23:21:14 2009
+++ merkaartor\MainWindow.cpp Mon Jan 05 00:13:09 2009
@@ -74,6 +74,7 @@
#include <QMenuBar>
#include <QTranslator>
#include <QLocale>
+#include <QMessageBox>
MainWindow::MainWindow(void)
: fileName(""), theDocument(0), theXmlDoc(0),
@@ -2136,21 +2137,29 @@
DefaultLanguage = QLocale::system().name();
qtTranslator = new QTranslator;
- qtTranslator->load("qt_" + DefaultLanguage
+ bool ret = qtTranslator->load("qt_" + DefaultLanguage
#ifdef TRANSDIR_SYSTEM
, TRANSDIR_SYSTEM
#else
, QLibraryInfo::location(QLibraryInfo::TranslationsPath)
#endif
);
- QCoreApplication::installTranslator(qtTranslator);
+ if (ret)
+ QCoreApplication::installTranslator(qtTranslator);
merkaartorTranslator = new QTranslator;
- merkaartorTranslator->load("merkaartor_" + DefaultLanguage
+ ret &= merkaartorTranslator->load("merkaartor_" + DefaultLanguage
#ifdef TRANSDIR_MERKAARTOR
, TRANSDIR_MERKAARTOR
+ #else
+ , QCoreApplication::applicationDirPath()
#endif
);
+ if (!ret)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Could not
load the selected language. Go to Tools, Preferences to select another language
or check whether the translation file is missing."));
+ return; // Language could not be loaded, do nothing (need to
restart programme)
+ }
QCoreApplication::installTranslator(merkaartorTranslator);
}
retranslateUi(this);
_______________________________________________
Merkaartor mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/merkaartor