Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]QNetworkAccessManager, QNetworkReply errorString() translation

[SOLVED]QNetworkAccessManager, QNetworkReply errorString() translation

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 9.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #2

    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...

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sidewinder
      wrote on last edited by
      #3

      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...

      "Never memorize what you can look up in books."
      Albert Einstein

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #4

        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).

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #5

          Those strings are set by Qt and are localizable. All you need to do is to set up your translator to load Qt translations as well (and eventually provide those translations for your language :-)). See what's inside $QTDIR/translations.

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sidewinder
            wrote on last edited by
            #6

            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.

            "Never memorize what you can look up in books."
            Albert Einstein

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #7

              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?

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sidewinder
                wrote on last edited by
                #8

                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.

                "Never memorize what you can look up in books."
                Albert Einstein

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dangelog
                  wrote on last edited by
                  #9

                  You're absolutely right, my fault. I'm investigating the problem.

                  Software Engineer
                  KDAB (UK) Ltd., a KDAB Group company

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dangelog
                    wrote on last edited by
                    #10

                    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).

                    Software Engineer
                    KDAB (UK) Ltd., a KDAB Group company

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dangelog
                      wrote on last edited by
                      #11

                      I've filed a bug and submitted a patch here. http://bugreports.qt.nokia.com/browse/QTBUG-18382

                      Software Engineer
                      KDAB (UK) Ltd., a KDAB Group company

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        sidewinder
                        wrote on last edited by
                        #12

                        Great! Thanks for help peppe and Gerolf. I'm going to recompile Qt right away. :)

                        "Never memorize what you can look up in books."
                        Albert Einstein

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved