From ecfde2869e5d820f217d5b91b408cba95409d17a Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 16 Jun 2014 10:16:49 +1000 Subject: [PATCH] Fully revert Translation resource idea --- sleepyhead/daily.cpp | 2 +- sleepyhead/translation.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 397bfc36..7f8a05ed 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -72,7 +72,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) ui->splitter_2->setSizes(a); ui->splitter_2->setStretchFactor(1,1); - layout=new QHBoxLayout(ui->graphMainArea); + layout=new QHBoxLayout(); layout->setSpacing(0); layout->setMargin(0); layout->setContentsMargins(0,0,0,0); diff --git a/sleepyhead/translation.cpp b/sleepyhead/translation.cpp index 0a27bd54..d52ba601 100644 --- a/sleepyhead/translation.cpp +++ b/sleepyhead/translation.cpp @@ -65,7 +65,7 @@ void initTranslations(QSettings & settings) { // Add default language (English) const QString en="en"; - langFiles[en]=""; + langFiles[en]="English.en.qm"; langNames[en]="English"; // Scan through available translations, and add them to the list @@ -121,11 +121,14 @@ void initTranslations(QSettings & settings) { for (QHash::iterator it = langNames.begin(); it != langNames.end(); ++it) { const QString & code = it.key(); const QString & name = it.value(); + if (!langFiles.contains(code) || langFiles[code].isEmpty()) + continue; + QListWidgetItem *item = new QListWidgetItem(name); item->setData(Qt::UserRole, code); langlist.insertItem(row++, item); // Todo: Use base system language code - if (code.compare("en")==0) { + if (code.compare("en") == 0) { langlist.setCurrentItem(item); } } @@ -146,12 +149,16 @@ void initTranslations(QSettings & settings) { langname=langNames[language]; langfile=langFiles[language]; - qDebug() << "Loading " << langname << " Translation" << langfile << "from" << transdir; - QTranslator * translator = new QTranslator(); + if (language.compare("en") != 0) { + qDebug() << "Loading " << langname << " Translation" << langfile << "from" << transdir; + QTranslator * translator = new QTranslator(); - if (!langfile.isEmpty() && !translator->load(langfile, transdir)) { - qWarning() << "Could not load translation" << langfile << "reverting to english :("; + if (!langfile.isEmpty() && !translator->load(langfile, transdir)) { + qWarning() << "Could not load translation" << langfile << "reverting to english :("; + } + + qApp->installTranslator(translator); + } else { + qDebug() << "Using in-built english Translation"; } - - qApp->installTranslator(translator); }