Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Ensure lupdate collects all the strings in tr() when using #ifdef for multiple OS



  • Hello

    I have an application which is deployed across Android, Windows and IOS.
    I have used #ifdef to separate the sourcecodes which are unique based on the OS.
    Now, when I run lupdate, on Windows, it does not recognise the strings marked with tr() in the sourcecode for Android or IOS.
    Is there a way to tell lupdate to consider all the strings irrespective of the #ifdef directive?

    Thanks for your consideration.

    KK


  • Lifetime Qt Champion

    Hi,

    What version of Qt are you using ?
    What #ifdef are you using ?



  • @SGaist
    I am using Qt 5.10
    I will explain the problem with some source code.

    #ifdef Q_OS_IOS
        QMessageBox msg;
        msg.setText(tr("This is the IOS Operating System."));
        msg.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
        msg.setDefaultButton(QMessageBox::No);
        msg.setParent(this);
        msg.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog);
        msg.setIcon(QMessageBox::Critical);
        int ret = msg.exec();
        if(ret==QMessageBox::No)
            return;
    #else
        QMessageBox msg;
        msg.setText(tr("This is not IOS Operating System."));
        msg.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
        msg.setDefaultButton(QMessageBox::No);
        msg.setParent(this);
        msg.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog);
        msg.setIcon(QMessageBox::Critical);
        int ret = msg.exec();
        if(ret==QMessageBox::No)
            return;
    #endif
    
    

    Now, when I am executing lupdate command from Windows, the message text "This is the IOS Operating System." does not get included in the messages for translations.
    How to ensure that even this message text will get included for translations.
    Thanks.



  • Hi @TheCrowKaka

    Can you share the cmd for lupdate ?
    Because the above code seems to be working fine on Windows

    Also can you try with Qt Creator directly ?
    Use kit of Windows ( I tried with MinGW 64-bit ) and Tools -> External -> Linguist -> Update Translations (lupdate)
    0_1560235511735_7518bee8-25b0-42e2-b66b-835de433ce0b-image.png

    i just tried,

    lupdate -verbose QtForum_Qt_103758.pro -ts test1.ts

    0_1560235121846_5dcc24fd-0468-436a-96e9-b918c61e8ec9-image.png

    0_1560235251041_72d18a3c-7db1-451d-9b2d-c6a292fcfa31-image.png


Log in to reply