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] i18n and linguist questions
QtWS25 Last Chance

[SOLVED] i18n and linguist questions

Scheduled Pinned Locked Moved General and Desktop
i18n
6 Posts 2 Posters 2.0k Views
  • 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 27 Mar 2015, 11:15 last edited by mrjj
    #1

    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
    0
    • M Offline
      M Offline
      mcosta
      wrote on 27 Mar 2015, 11:27 last edited by
      #2

      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
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 27 Mar 2015, 11:53 last edited by
        #3

        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
        0
        • M Offline
          M Offline
          mcosta
          wrote on 27 Mar 2015, 12:18 last edited by mcosta
          #4

          @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
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 27 Mar 2015, 12:33 last edited by
            #5

            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
            0
            • M Offline
              M Offline
              mcosta
              wrote on 27 Mar 2015, 12:36 last edited by
              #6

              @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
              0

              1/6

              27 Mar 2015, 11:15

              • Login

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