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. Ensure lupdate collects all the strings in tr() when using #ifdef for multiple OS

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 489 Views 3 Watching
  • 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.
  • T Offline
    T Offline
    TheCrowKaka
    wrote on last edited by
    #1

    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

    A Qt Enthusiastic...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

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

        T Offline
        T Offline
        TheCrowKaka
        wrote on last edited by
        #3

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

        A Qt Enthusiastic...

        1 Reply Last reply
        0
        • Pradeep P NP Offline
          Pradeep P NP Offline
          Pradeep P N
          wrote on last edited by Pradeep P N
          #4

          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

          Pradeep Nimbalkar.
          Upvote the answer(s) that helped you to solve the issue...
          Keep code clean.

          1 Reply Last reply
          3

          • Login

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