diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index fa473f30c..bd32a1334 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -410,10 +410,8 @@ void MainWindow::ProgramSettings() dialog.SaveFullPath(), dialog.SaveAllErrors(), dialog.ShowNoErrorsMessage()); - const QString currentLang = mTranslation->GetCurrentLanguage(); const QString newLang = mSettings->value(SETTINGS_LANGUAGE, "en").toString(); - if (currentLang != newLang) - SetLanguage(newLang); + SetLanguage(newLang); } } @@ -650,20 +648,18 @@ void MainWindow::FormatAndSetTitle(const QString &text) setWindowTitle(title); } - void MainWindow::SetLanguage(const QString &code) { - if (mTranslation->GetCurrentLanguage() == code) - { + const QString currentLang = mTranslation->GetCurrentLanguage(); + if (currentLang == code) return; - } QString error; if (!mTranslation->SetLanguage(code, error)) { QMessageBox msg(QMessageBox::Critical, tr("Cppcheck"), - QString(tr("Failed to change the language:\n\n%1\n\n")).arg(error), + QString(tr("Failed to change the language:\n\n%1")).arg(error), QMessageBox::Ok, this); diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index 0ff727cbe..6a1cb1d9a 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -24,6 +24,7 @@ TranslationHandler::TranslationHandler(QObject *parent) : QObject(parent), + mCurrentLanguage("en"), mTranslator(new QTranslator(this)) { // Add our available languages @@ -85,7 +86,7 @@ bool TranslationHandler::SetLanguage(const QString &code, QString &error) int index = GetLanguageIndexByCode(code); if (index == -1) { - error = QObject::tr("Incorrect language specified!"); + error = QObject::tr("Unknown language specified!"); return false; }