Fix QNetworkReply::errorString returning an untranslated string
authorGiuseppe D'Angelo <dangelog@gmail.com>
Mon, 12 Sep 2011 16:43:21 +0000 (18:43 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Sep 2011 18:59:47 +0000 (20:59 +0200)
The QHttpNetworkConnectionPrivate::errorDetail is supposed to return a
translated string, which is then set as the QNetworkReply error.
The current code incorrectly uses QT_TRANSLATE_NOOP,
which mark the strings for translation, but does not translate them.
The result is that even with a translator loaded those strings are
written in English.

Fixes QTBUG-18382.

Merge-request: 2671
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
(cherry picked from commit 434686a926a2a6e71f3cdea2508898b7800f7c81)

Change-Id: I8673cef7671d41106f50b75e78394916f3b720c9
Reviewed-on: http://codereview.qt-project.org/4691
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/network/access/qhttpnetworkconnection.cpp

index fc4eccc..c368785 100644 (file)
@@ -49,6 +49,7 @@
 #include "private/qhostinfo_p.h"
 #include <qnetworkproxy.h>
 #include <qauthenticator.h>
+#include <qcoreapplication.h>
 
 #include <qbuffer.h>
 #include <qpair.h>
@@ -720,32 +721,31 @@ QString QHttpNetworkConnectionPrivate::errorDetail(QNetworkReply::NetworkError e
     QString errorString;
     switch (errorCode) {
     case QNetworkReply::HostNotFoundError:
-        errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QHttp", "Host %1 not found"))
-                              .arg(socket->peerName());
+        errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(socket->peerName());
         break;
     case QNetworkReply::ConnectionRefusedError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Connection refused"));
+        errorString = QCoreApplication::translate("QHttp", "Connection refused");
         break;
     case QNetworkReply::RemoteHostClosedError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Connection closed"));
+        errorString = QCoreApplication::translate("QHttp", "Connection closed");
         break;
     case QNetworkReply::TimeoutError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QAbstractSocket", "Socket operation timed out"));
+        errorString = QCoreApplication::translate("QAbstractSocket", "Socket operation timed out");
         break;
     case QNetworkReply::ProxyAuthenticationRequiredError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Proxy requires authentication"));
+        errorString = QCoreApplication::translate("QHttp", "Proxy requires authentication");
         break;
     case QNetworkReply::AuthenticationRequiredError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Host requires authentication"));
+        errorString = QCoreApplication::translate("QHttp", "Host requires authentication");
         break;
     case QNetworkReply::ProtocolFailure:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Data corrupted"));
+        errorString = QCoreApplication::translate("QHttp", "Data corrupted");
         break;
     case QNetworkReply::ProtocolUnknownError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "Unknown protocol specified"));
+        errorString = QCoreApplication::translate("QHttp", "Unknown protocol specified");
         break;
     case QNetworkReply::SslHandshakeFailedError:
-        errorString = QLatin1String(QT_TRANSLATE_NOOP("QHttp", "SSL handshake failed"));
+        errorString = QCoreApplication::translate("QHttp", "SSL handshake failed");
         break;
     default:
         // all other errors are treated as QNetworkReply::UnknownNetworkError