Important: Please read the Qt Code of Conduct -

[SOLVED] i18n and linguist questions

  • Lifetime Qt Champion

    Trying to learn how to do i18n the QT way.
    Using sample

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

  • 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

  • Lifetime Qt Champion

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

    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

  • @mrjj said:

    can it dynamic change in an object life span ?

    You can handle language change at runtime using this example

    void Widget::changeEvent(QEvent *e)
        switch (e->type()) {
        case QEvent::LanguageChange:

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

  • Lifetime Qt Champion

    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 ?

  • @mrjj said:

    Final question: Where is Resolved function hidden ?

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

Log in to reply