Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED] i18n and linguist questions

    General and Desktop
    i18n
    2
    6
    1405
    Loading More Posts
    • 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.
    • mrjj
      mrjj Lifetime Qt Champion last edited by mrjj

      Hi
      Trying to learn how to do i18n the QT way.
      Using sample
      Qt-5.3\widgets\tools\i18n

      1. When I open a TS file with linguist .exe
        It ask which source and target. (in a small dialog)

      So it has no idea what language the file actually contains?
      If I choose wrong, will it damage the file?

      One option for language is POSIX.
      Which means c locale ? or how to read that.

      1. In this sample, it shows a dialog that change language for the main window.
        I then changed the a button text in this Dialog from "show all" to tr("Show'em")
        I ran the tools and my TS file now contains this new entry "Show'em". which i translated and
        compiled new QM file.
        BUT
        When I load the language file, the button text never changes in the Dialog.
        so my QUESTIONS are
        Do I have to recreate the dialog to make it use new text or should it be dynamic ?
        its uses
        qApp->installTranslator(&translator);
        so it seems to be app wide, so why is button not using translated text?
        I assume that the "use translation" flag on widgets are on by default.

      Thank you

      1 Reply Last reply Reply Quote 0
      • M
        mcosta last edited by

        Hi,

        1. these are only information about the contents. IMO you cannot damage the file
        2. You're right
        3. Is the .qm file part of applications resources? if YES you should rebuild the app because the translations are embedded into the application itself

        Happy Translating

        Once your problem is solved don't forget to:

        • Mark the thread as SOLVED using the Topic Tool menu
        • Vote up the answer(s) that helped you to solve the issue

        You can embed images using (http://imgur.com/) or (http://postimage.org/)

        1 Reply Last reply Reply Quote 0
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          Hi
          1: ok, its mostly just to show which correct label for
          translation and not really important.

          3:
          Yes, in this sample its part of a res.
          I have cleaned and rebuild. It can load it.

          But The dialog's button does not change. so I guess i do not know if
          it can be that dynamic. The dialog will create a new main window object when language changes.
          The dialog is same object until app.exit. So I will need to delete and recreate the dialog before it can change language or
          can it dynamic change in an object life span ?

          so I guess question is.
          for an object. already created. can its texts be change without new(ing)it again ?

          thank you

          1 Reply Last reply Reply Quote 0
          • M
            mcosta last edited by mcosta

            @mrjj said:

            or
            can it dynamic change in an object life span ?

            You can handle language change at runtime using this example

            void Widget::changeEvent(QEvent *e)
            {
                QWidget::changeEvent(e);
                switch (e->type()) {
                case QEvent::LanguageChange:
                    ui->retranslateUi(this);
                    break;
                default:
                    break;
                }
            }
            

            It works if you have a .ui file for the dialog

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion last edited by

              oh, that looks sort of promising.
              In sample, (like most) no UI files is used. all code.
              They seems to love doing it in code. :)

              I will browse the qt code and see what retranslateUi really does.

              Thank you

              Final question: Where is Resolved function hidden ?

              1 Reply Last reply Reply Quote 0
              • M
                mcosta last edited by

                @mrjj said:

                Final question: Where is Resolved function hidden ?

                You can change the post title adding a [SOLVED] prefix

                Once your problem is solved don't forget to:

                • Mark the thread as SOLVED using the Topic Tool menu
                • Vote up the answer(s) that helped you to solve the issue

                You can embed images using (http://imgur.com/) or (http://postimage.org/)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post