Skip to content
  • 0 Votes
    13 Posts
    2k Views
    C

    @KroMignon Hey! I forgot to answer to you! Did not meant to be rude and sorry for that :(
    Conclusion: I gave some tries with your suggest and lots of other stuff on internet, but failed :D
    So I have created a "Restart the system to apply all the language changes" screen and a "restart/cancel" choice on a language change state. I guess it will be okay even if it wont be "real-time" :P
    Good Work!

  • 0 Votes
    3 Posts
    561 Views
    C

    @KroMignon LOVE YOU!
    Thank you very much, worked w/out problems, and made me understand my mistake.
    note: Needed to update .ts file and release .qm file after changing code.

  • Lupdate and macros

    Unsolved General and Desktop
    3
    0 Votes
    3 Posts
    1k Views
    Pablo J. RoginaP

    @sailor.steve said in Lupdate and macros:

    I wrapped the text in macros that need to be translated

    In addition to @sierdzio response, please keep in mind that Qt translation tools use the "original" text as the key for looking the proper translation in the available loaded Qt translator object, and if such string is not found, that same string is displayed instead.

    This is a little bit different from some other translation tools that use "constants" (i.e. macro?) as the key and then you provide a file with constant -> translation pairs.

  • 0 Votes
    11 Posts
    6k Views
    O

    @mrjj okay - thanks for help!

  • 0 Votes
    9 Posts
    3k Views
    ?

    @Rohith I don't know. Use Google Search to find it out!

  • 0 Votes
    3 Posts
    1k Views
    SeeLookS

    Another solution that not require hacking Qt is to alias QApplication::translate method:

    inline QString myTr(const char* context, const char* key, const char* disambiguation = 0, int n = -1) { return QApplication::translate(context, key, disambiguation, n); }

    and then get translated text with:

    myTr("QShortcut", "Help");

    Such texts are invisible for lupdate.

  • 0 Votes
    2 Posts
    1k Views
    p3c0P

    Hi @antemort,
    It can't be done purely in QML. You will need to use sockets on C++ side. Qt has C++ API's for sockets. QTcpServer creates a server and QTcpSocket for client. After that you will need to expose them to QML.
    Edit: Some one has tried to do that already. See https://github.com/jemc/qml-sockets

  • 0 Votes
    10 Posts
    7k Views
    A

    Below is an answer.

    void MyWidget::changeEvent(QEvent *event)
    {
    if (e->type() == QEvent::LanguageChange) {
    titleLabel->setText(tr("Document Title"));
    ...
    okPushButton->setText(tr("&OK"));
    } else
    QWidget::changeEvent(event);
    }

    code within if (e->type() == QEvent::LanguageChange) { ... )
    should contain ALL the code which has to be called when language changed.
    Basically every line of the code with tr() has to be called there.

    In there you can put call to retranslateUi,
    but retranslateUi is just a function where QtDesigner put strings created in there.
    this might be or might not be sufficient for your widget.
    Finally there are people who do not use designer.
    That is why you could not find retranslateUi mentioned anywhere.
    Keyword is tr().

    For example you may fill tree widget outside of designer.
    If you used text which has to be internationalized there, you need to make sure the same code is executed as a reaction on language changed.

    Common logic suggests to put all code which requires initialization in a single function or slot.
    Such function or slot should be called when QEvent::LanguageChange arrives.
    Call this function myRetranslateUi if you want.

    You do not have to subclass every widget (as suggested by example) though.
    Alternative is to install event filter.

  • 0 Votes
    1 Posts
    677 Views
    No one has replied