From a7c1d99d019fc865f1d7863162569ae6576d88de Mon Sep 17 00:00:00 2001 From: Vesa Pikki Date: Sat, 4 Jul 2009 12:06:31 +0300 Subject: [PATCH] I reverted back the translation file checking. Allthough I put it after QTranslator had failed to load the translation. This still allows QTranslator to try and open the file with several variations of the file. To user we'll tell that the default file is missing. --- gui/cppcheck_de.ts | 65 +++++++++++++++++-------- gui/cppcheck_en.ts | 93 +++++++++++++++++++----------------- gui/cppcheck_fi.ts | 97 +++++++++++++++++++++----------------- gui/cppcheck_ru.ts | 65 +++++++++++++++++-------- gui/cppcheck_se.ts | 65 +++++++++++++++++-------- gui/translationhandler.cpp | 24 +++++++--- 6 files changed, 259 insertions(+), 150 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index 683491e2e..b2aa0aff4 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -18,7 +18,7 @@ Cppcheck - A tool for static C/C++ code analysis. - + Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -116,10 +116,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck @@ -284,59 +284,59 @@ kate -l(line) (file) - + Select files to check - + Select directory to check - + No suitable files found to check! - + Cannot exit while checking. Stop the checking before exiting. - + License - + Authors - + XML files (*.xml);;Text files (*.txt) - + Save the report file - + XML files (*.xml) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -347,6 +347,31 @@ Stop the checking before exiting. %1 + + + Finnish + + + + + English + + + + + Swedish + + + + + German + + + + + Russian + + QObject @@ -356,13 +381,15 @@ Stop the checking before exiting. - - Language file %1.qm not found! + + Language file %1 not found! + Language file %1.qm not found! - Failed to load language from file %1 + Failed to load translation for language %1 from file %2 + Failed to load translation for language %1 from file %2.qm diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 71843de9b..8ddee44eb 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -18,7 +18,7 @@ Cppcheck - A tool for static C/C++ code analysis. Cppcheck - A tool for static C/C++ code analysis. - + Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -129,10 +129,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck @@ -297,22 +297,22 @@ kate -l(line) (file) &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + Cannot exit while checking. Stop the checking before exiting. @@ -321,37 +321,37 @@ Stop the checking before exiting. Stop the checking before exiting. - + License License - + Authors Authors - + XML files (*.xml);;Text files (*.txt) XML files (*.xml);;Text files (*.txt) - + Save the report file Save the report file - + XML files (*.xml) XML files (*.xml) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -360,47 +360,54 @@ Stop the checking before exiting. Failed to change language: %1 - Failed to change language: + Failed to change language: %1 + + + Finnish + Finnish + + + + English + English + + + + Swedish + Swedish + + + + German + German + + + + Russian + Russian + QObject - - English - English - - - Finnish - Finnish - - - Swedish - Swedish - - - German - German - - - Russian - Russian - Incorrect language specified! Incorrect language specified! - - Language file %1.qm not found! - + + Language file %1 not found! + Language file %1.qm not found! + Could not find the file: %1! - Failed to load language from file %1 - Failed to load language from file %1 + Failed to load translation for language %1 from file %2 + Failed to load translation for language %1 from file %2.qm + Failed to load translation for language %1 from file %2 @@ -453,7 +460,7 @@ Stop the checking before exiting. Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - You can open this error by specifying applications in program's settings. + You can open this error by specifying applications in program's settings. diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 1f327b6f1..361ba3f91 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -18,7 +18,7 @@ Cppcheck - A tool for static C/C++ code analysis. Cppcheck - Työkalu C/C++ koodin staattiseen analysointiin. - + Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. Copyright (C) 2007-2009 Daniel Marjamäki ja cppcheck tiimi. @@ -131,10 +131,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck @@ -299,22 +299,22 @@ kate -l(line) (file) &Ohje - + Select files to check Valitse tarkistettavat tiedostot - + Select directory to check Valitse tarkistettava hakemisto - + No suitable files found to check! Tarkistettavaksi sopivia tiedostoja ei löytynyt! - + Cannot exit while checking. Stop the checking before exiting. @@ -323,37 +323,37 @@ Stop the checking before exiting. Lopeta tarkistus ennen ohjelman sammuttamista. - + License Lisenssi - + Authors Tekijät - + XML files (*.xml);;Text files (*.txt) XML-tiedostot (*.xml);;Tekstitiedostot (*.txt) - + Save the report file Tallenna raportti - + XML files (*.xml) XML-tiedostot (*xml) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -362,45 +362,56 @@ Lopeta tarkistus ennen ohjelman sammuttamista. Failed to change language: %1 - Kielen %1 vaihto epäonnistui + Ohjelman kielen vaihtaminen epäonnistui: + +%1 + + + + + + Finnish + Suomi + + + + English + Englanti + + + + Swedish + Ruotsi + + + + German + Saksa + + + + Russian + Venäjä QObject - - English - Englanti - - - Finnish - Suomi - - - Swedish - Ruotsi - - - German - Saksa - - - Russian - Venäjä - Incorrect language specified! Virheellinen kieli valittu! - - Language file %1.qm not found! - + + Language file %1 not found! + Language file %1.qm not found! + Käännöstiedostoa %1 ei löytynyt! - Failed to load language from file %1 - Kielen lataaminen tiedostosta %1 epäonnistui + Failed to load translation for language %1 from file %2 + Failed to load translation for language %1 from file %2.qm + Käänöksen lataaminen kielelle %1 tiedostosta %2 epäonnistui @@ -453,7 +464,7 @@ Lopeta tarkistus ennen ohjelman sammuttamista. Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. + Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 58d74a3c7..15be0f364 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -18,7 +18,7 @@ Cppcheck - A tool for static C/C++ code analysis. - + Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -118,10 +118,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck @@ -286,59 +286,59 @@ kate -l(line) (file) - + Select files to check - + Select directory to check - + No suitable files found to check! - + Cannot exit while checking. Stop the checking before exiting. - + License - + Authors - + XML files (*.xml);;Text files (*.txt) - + Save the report file - + XML files (*.xml) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -349,6 +349,31 @@ Stop the checking before exiting. %1 + + + Finnish + + + + + English + + + + + Swedish + + + + + German + + + + + Russian + + QObject @@ -358,13 +383,15 @@ Stop the checking before exiting. - - Language file %1.qm not found! + + Language file %1 not found! + Language file %1.qm not found! - Failed to load language from file %1 + Failed to load translation for language %1 from file %2 + Failed to load translation for language %1 from file %2.qm diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 58d74a3c7..15be0f364 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -18,7 +18,7 @@ Cppcheck - A tool for static C/C++ code analysis. - + Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team. @@ -118,10 +118,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck @@ -286,59 +286,59 @@ kate -l(line) (file) - + Select files to check - + Select directory to check - + No suitable files found to check! - + Cannot exit while checking. Stop the checking before exiting. - + License - + Authors - + XML files (*.xml);;Text files (*.txt) - + Save the report file - + XML files (*.xml) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -349,6 +349,31 @@ Stop the checking before exiting. %1 + + + Finnish + + + + + English + + + + + Swedish + + + + + German + + + + + Russian + + QObject @@ -358,13 +383,15 @@ Stop the checking before exiting. - - Language file %1.qm not found! + + Language file %1 not found! + Language file %1.qm not found! - Failed to load language from file %1 + Failed to load translation for language %1 from file %2 + Failed to load translation for language %1 from file %2.qm diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index 5c52346b4..d1c758f9a 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -28,11 +28,11 @@ TranslationHandler::TranslationHandler(QObject *parent) : mTranslator(new QTranslator(this)) { //Add our default languages - mNames << "English" - << "Finnish" - << "Swedish" - << "German" - << "Russian"; + mNames << QT_TRANSLATE_NOOP("MainWindow","English") + << QT_TRANSLATE_NOOP("MainWindow","Finnish") + << QT_TRANSLATE_NOOP("MainWindow","Swedish") + << QT_TRANSLATE_NOOP("MainWindow","German") + << QT_TRANSLATE_NOOP("MainWindow","Russian"); mFiles << "cppcheck_en" << "cppcheck_fi" @@ -92,8 +92,18 @@ bool TranslationHandler::SetLanguage(const int index, QString &error) //Load the new language if (!mTranslator->load(mFiles[index])) { - error = QObject::tr("Failed to load language from file %1"); - error = error.arg(mFiles[index]); + //If it failed, lets check if the default file exists + if (!QFile::exists(mFiles[index]+".qm")) + { + error = QObject::tr("Language file %1 not found!"); + error = error.arg(mFiles[index]+".qm"); + return false; + } + + //If file exists, there's something wrong with it + error = QObject::tr("Failed to load translation for language %1 from file %2"); + error = error.arg(mNames[index]); + error = error.arg(mFiles[index]+".qm"); return false; }