Fully revert Translation resource idea

This commit is contained in:
Mark Watkins 2014-06-16 10:16:49 +10:00
parent a96cff0047
commit ecfde2869e
2 changed files with 16 additions and 9 deletions

View File

@ -72,7 +72,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
ui->splitter_2->setSizes(a); ui->splitter_2->setSizes(a);
ui->splitter_2->setStretchFactor(1,1); ui->splitter_2->setStretchFactor(1,1);
layout=new QHBoxLayout(ui->graphMainArea); layout=new QHBoxLayout();
layout->setSpacing(0); layout->setSpacing(0);
layout->setMargin(0); layout->setMargin(0);
layout->setContentsMargins(0,0,0,0); layout->setContentsMargins(0,0,0,0);

View File

@ -65,7 +65,7 @@ void initTranslations(QSettings & settings) {
// Add default language (English) // Add default language (English)
const QString en="en"; const QString en="en";
langFiles[en]=""; langFiles[en]="English.en.qm";
langNames[en]="English"; langNames[en]="English";
// Scan through available translations, and add them to the list // Scan through available translations, and add them to the list
@ -121,11 +121,14 @@ void initTranslations(QSettings & settings) {
for (QHash<QString, QString>::iterator it = langNames.begin(); it != langNames.end(); ++it) { for (QHash<QString, QString>::iterator it = langNames.begin(); it != langNames.end(); ++it) {
const QString & code = it.key(); const QString & code = it.key();
const QString & name = it.value(); const QString & name = it.value();
if (!langFiles.contains(code) || langFiles[code].isEmpty())
continue;
QListWidgetItem *item = new QListWidgetItem(name); QListWidgetItem *item = new QListWidgetItem(name);
item->setData(Qt::UserRole, code); item->setData(Qt::UserRole, code);
langlist.insertItem(row++, item); langlist.insertItem(row++, item);
// Todo: Use base system language code // Todo: Use base system language code
if (code.compare("en")==0) { if (code.compare("en") == 0) {
langlist.setCurrentItem(item); langlist.setCurrentItem(item);
} }
} }
@ -146,12 +149,16 @@ void initTranslations(QSettings & settings) {
langname=langNames[language]; langname=langNames[language];
langfile=langFiles[language]; langfile=langFiles[language];
qDebug() << "Loading " << langname << " Translation" << langfile << "from" << transdir; if (language.compare("en") != 0) {
QTranslator * translator = new QTranslator(); qDebug() << "Loading " << langname << " Translation" << langfile << "from" << transdir;
QTranslator * translator = new QTranslator();
if (!langfile.isEmpty() && !translator->load(langfile, transdir)) { if (!langfile.isEmpty() && !translator->load(langfile, transdir)) {
qWarning() << "Could not load translation" << langfile << "reverting to english :("; qWarning() << "Could not load translation" << langfile << "reverting to english :(";
}
qApp->installTranslator(translator);
} else {
qDebug() << "Using in-built english Translation";
} }
qApp->installTranslator(translator);
} }