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. Translate QDialogButtonBox
Forum Updated to NodeBB v4.3 + New Features

Translate QDialogButtonBox

Scheduled Pinned Locked Moved General and Desktop
25 Posts 4 Posters 10.8k 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.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on last edited by
    #13

    Sorry for raising the topic, i was kinda busy.

    In my test did not work

    @int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QTranslator translation;
    translation.load("translations/core_connecdialog_ptBr.ts");

    Testdataaccess testdataaccess(&app);
    Testconnecdialog testconnecdialog(&app);
    Testdynamicqtwidgets testedynamicqtwidgets(&app);

    //QTest::qExec(&testedynamicqtwidgets, argc, argv);
    //QTest::qExec(&testdataaccess, argc, argv);
    QTest::qExec(&testconnecdialog, argc, argv);

    app.installTranslator(&translation);
    app.exec();
    }@

    .ts files can be used directly @translation.load("translations/core_connecdialog_ptBr.ts")@ or is necessary to run lrelease?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #14

      ts files are "internationalization sources". You have to run lrelease to get the file for QTranslator to use.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Exotic_Devel
        wrote on last edited by
        #15

        Ok, I run lrelease, qm file was generated, however, nothing was translated. Everything is still in English.

        My main.cpp

        @int main(int argc, char *argv[])
        {
        QApplication app(argc, argv);
        QTranslator translation;
        translation.load("translations/core_connecdialog_ptBr");

        Testdataaccess testdataaccess(&app);
        Testconnecdialog testconnecdialog(&app);
        Testdynamicqtwidgets testedynamicqtwidgets(&app);

        //QTest::qExec(&testedynamicqtwidgets, argc, argv);
        //QTest::qExec(&testdataaccess, argc, argv);
        QTest::qExec(&testconnecdialog, argc, argv);

        app.installTranslator(&translation);
        app.exec();
        }
        @

        !http://i60.tinypic.com/wh1c48.png(MyLinguist)!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cincirin
          wrote on last edited by
          #16

          Basically you have two errors:
          a) check the return value of translation.load(...) to be sure the translation is correctly loaded
          b) I'm not 100% sure about this, but you call installTranslator after your Ui is created. I think in this way you'll have to retranslate the Ui (check dynamic translation in the docs). Anyway, try to move installTranslator before the widgets are created

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Exotic_Devel
            wrote on last edited by
            #17

            Ok, worked

            @int main(int argc, char *argv[])
            {
            QApplication app(argc, argv);
            QTranslator translation;

            translation.load("translations/core_connecdialog_ptBr");

            app.installTranslator(&translation);

            Testdataaccess testdataaccess(&app);
            Testconnecdialog testconnecdialog(&app);
            Testdynamicqtwidgets testedynamicqtwidgets(&app);

            //QTest::qExec(&testedynamicqtwidgets, argc, argv);
            //QTest::qExec(&testdataaccess, argc, argv);
            QTest::qExec(&testconnecdialog, argc, argv);

            app.exec();
            }
            @

            but QDialogButtonBox is not translated.
            I added QT_TRANSLATE_NOOP, did the translation with Qt Linguist. But still in english.

            !http://i60.tinypic.com/2nsary8.png(QDialogButtonBox)!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #18

              Do you have

              @translation.load("translations/core_connecdialog_ptBr");@

              in the same folder as your executable ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cincirin
                wrote on last edited by
                #19

                @Exotic_Devel: your linguist seems to be un-translated. If I look at ConecConfDialog source there are 0(zero) items translated from 7. The same for QPlatformTheme, there are 0(zero) items from 5 translated.

                So, I don't know how your binary application is ever translated. Maybe it is looking for other "lrelease"-ed translation ? (not the one from screenshot)

                edit: make sure you save the linguist translation before the "lrelease"

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  Exotic_Devel
                  wrote on last edited by
                  #20

                  Ok, in Qt Linguist lacked [Translation] => [Done and Next] menu, but is still without translation. Below the images.

                  !http://i61.tinypic.com/34tea2e.png(mylinguist)!
                  !http://i58.tinypic.com/6teqlj.png(mydir)!
                  !http://i59.tinypic.com/21lr3ps.png(mydir2)!

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    Exotic_Devel
                    wrote on last edited by
                    #21

                    Ok, in Qt Linguist lacked [Translation] => [Done and Next] menu, but is still without translation. Below the images.

                    !http://i61.tinypic.com/34tea2e.png(mylinguist)!
                    !http://i58.tinypic.com/6teqlj.png(mydir)!
                    !http://i59.tinypic.com/21lr3ps.png(mydir2)!

                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      Exotic_Devel
                      wrote on last edited by
                      #22

                      Saved and used again lrelease

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        Exotic_Devel
                        wrote on last edited by
                        #23

                        Saved and used again lrelease

                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          Exotic_Devel
                          wrote on last edited by
                          #24

                          Unfortunately the solution with QT_TRANSLATE_NOOP did not solve. I opted for the solution mentioned by SGaist.

                          @qdbb_okcancel->button(QDialogButtonBox::Cancel)->setText(tr("&Cancel"));
                          @

                          Now the translation works well

                          Thank you all

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            Exotic_Devel
                            wrote on last edited by
                            #25

                            Unfortunately the solution with QT_TRANSLATE_NOOP did not solve. I opted for the solution mentioned by SGaist.

                            @qdbb_okcancel->button(QDialogButtonBox::Cancel)->setText(tr("&Cancel"));
                            @

                            Now the translation works well

                            Thank you all

                            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