[SOLVED]QNetworkAccessManager, QNetworkReply errorString() translation
-
Hi,
your description is not correct, QNetworkAccessManager has no method errorString(), so it can't be translated :-)
I suppose you mean QNetworkReply::errorString().
If you look at the code of QNetworkReply, you see that the string is set from somewhere else :-(.
If you scan the code, it seems the errors are translated there... -
Right, I messed up classes names. Already fixed that. Thanks.
I'd searched for translations in ts files and I found some error strings translated but in QAbstractSocket (which is direct parent of QTcpSocket). I wasn't able to find any relevant translations neither in QNetworkReply nor in QIODevice...
-
It is not translated via QIODevice, it uses QCoreApplication::translate
Its in the classes, not directly in QNetworkReply. QNetworkReply has a method setError(...) which is called by QNetwork... (forgotten the exact class, read the classes QNetworkAccessManager and used classes).
-
Lines 50 and 51 are loading Qt translations. I'd be happy to translate missing error strings but I can't find them. Loading qt_pl.ts into Linguist shows only a few untranslated entries and none of them is connected with network context. Moreover it seems that QNetworkReply::errorString() returns english error string no matter which translation I try (wrote about that in first post). I'm sure Qt translations are loaded correctly because QTcpSocket error strings are translated.
-
Hi Pepe,
that was exactly what he did. Look at line 5:@
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTranslator qtTranslator;
qtTranslator.load("qt_pl",QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator);Test test; test.startConnection(); test.connect(&test,SIGNAL(finished()),&a,SLOT(quit())); return a.exec();}
@And he said, for other classes he gets correct translated strings.
It should work if Qt is build and installed correctly.@ sidewinder: did you check whether qtTranslator.load works fine?
-
Yep. qtTranslator.load(...) returns true.
All other translations like context menus, other classes error strings, widgets default tooltips are loaded correctly.
To be 101% sure I've just added new line to main function:
@qDebug() << qtTranslator.translate("QHttp","Unknown error");@
Which prints another line in console with correct translation. -
Qt bug. The strings in here
http://qt.gitorious.org/qt/qt/blobs/master/src/network/access/qhttpnetworkconnection.cpp#line637
are not translated (since QT_TRANSLATE_NOOP marks them for translation, but doesn't actually translate them).
-
I've filed a bug and submitted a patch here. http://bugreports.qt.nokia.com/browse/QTBUG-18382
-
Great! Thanks for help peppe and Gerolf. I'm going to recompile Qt right away. :)