Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. LUpdate not adding entry to .ts file
Forum Update on Tuesday, May 27th 2025

LUpdate not adding entry to .ts file

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 330 Views 2 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.
  • P Offline
    P Offline
    Perdrix
    wrote on 29 Apr 2023, 10:02 last edited by Perdrix
    #1

    This fails:

    strText = QCoreApplication::translate("LiveEngine", "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
    	"IDS_LOG_REGISTERRESULTS", 
            static_cast<int>(lfi.m_vStars.size()))
    	.arg(QString::fromWCharArray(strName)
            .arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));
    

    This works:

    strText = QCoreApplication::translate("LiveEngine", "Image %1 registered: %2 star(s) detected - FWHM = %3 - Score = %4\n",
    	"IDS_LOG_REGISTERRESULTS")
    	.arg(QString::fromWCharArray(strName)
    	.arg(lfi.m_vStars.size())
    	.arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));
    

    Puzzled

    P 1 Reply Last reply 29 Apr 2023, 12:52
    0
    • P Perdrix
      29 Apr 2023, 10:02

      This fails:

      strText = QCoreApplication::translate("LiveEngine", "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
      	"IDS_LOG_REGISTERRESULTS", 
              static_cast<int>(lfi.m_vStars.size()))
      	.arg(QString::fromWCharArray(strName)
              .arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));
      

      This works:

      strText = QCoreApplication::translate("LiveEngine", "Image %1 registered: %2 star(s) detected - FWHM = %3 - Score = %4\n",
      	"IDS_LOG_REGISTERRESULTS")
      	.arg(QString::fromWCharArray(strName)
      	.arg(lfi.m_vStars.size())
      	.arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));
      

      Puzzled

      P Offline
      P Offline
      Paul Colby
      wrote on 29 Apr 2023, 12:52 last edited by
      #2

      Hi @Perdrix

      .arg(QString::fromWCharArray(strName)
      .arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));

      I think that very last ) should be on the previous line.

      You have:

      strText = QCoreApplication::translate(
          "LiveEngine",
          "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
          "IDS_LOG_REGISTERRESULTS", 
          static_cast<int>(lfi.m_vStars.size())
      )
      .arg(
           QString::fromWCharArray(strName)
              .arg(lfi.m_fFWHM, 0, 'f', 2)
              .arg(lfi.m_fOverallQuality, 0, 'f', 2)
      );
      

      I suspect you meant:

      strText = QCoreApplication::translate(
          "LiveEngine",
          "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
          "IDS_LOG_REGISTERRESULTS", 
          static_cast<int>(lfi.m_vStars.size())
      )
      .arg(QString::fromWCharArray(strName)) ///< Extra `)` here.
      .arg(lfi.m_fFWHM, 0, 'f', 2)
      .arg(lfi.m_fOverallQuality, 0, 'f', 2); ///< One less `)` here.
      

      Cheers.

      J P 2 Replies Last reply 29 Apr 2023, 13:14
      2
      • P Paul Colby
        29 Apr 2023, 12:52

        Hi @Perdrix

        .arg(QString::fromWCharArray(strName)
        .arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));

        I think that very last ) should be on the previous line.

        You have:

        strText = QCoreApplication::translate(
            "LiveEngine",
            "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
            "IDS_LOG_REGISTERRESULTS", 
            static_cast<int>(lfi.m_vStars.size())
        )
        .arg(
             QString::fromWCharArray(strName)
                .arg(lfi.m_fFWHM, 0, 'f', 2)
                .arg(lfi.m_fOverallQuality, 0, 'f', 2)
        );
        

        I suspect you meant:

        strText = QCoreApplication::translate(
            "LiveEngine",
            "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
            "IDS_LOG_REGISTERRESULTS", 
            static_cast<int>(lfi.m_vStars.size())
        )
        .arg(QString::fromWCharArray(strName)) ///< Extra `)` here.
        .arg(lfi.m_fFWHM, 0, 'f', 2)
        .arg(lfi.m_fOverallQuality, 0, 'f', 2); ///< One less `)` here.
        

        Cheers.

        J Offline
        J Offline
        JonB
        wrote on 29 Apr 2023, 13:14 last edited by
        #3

        @Paul-Colby
        That's the trouble with any offering like Qt's with %num substitutions not supported/checked by the language (C++) :(

        With Qt QString::arg() you get a run-time warning if you supplied too many arguments for the %ns and nothing at all if you supplied too few. gcc at least gives you compile-time warnings for both too many and too few if you use printf("%...", ...)-type functions, and my old favourite C# had built-in support in the language for {n} substitutions so could do the same.

        1 Reply Last reply
        0
        • P Paul Colby
          29 Apr 2023, 12:52

          Hi @Perdrix

          .arg(QString::fromWCharArray(strName)
          .arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2));

          I think that very last ) should be on the previous line.

          You have:

          strText = QCoreApplication::translate(
              "LiveEngine",
              "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
              "IDS_LOG_REGISTERRESULTS", 
              static_cast<int>(lfi.m_vStars.size())
          )
          .arg(
               QString::fromWCharArray(strName)
                  .arg(lfi.m_fFWHM, 0, 'f', 2)
                  .arg(lfi.m_fOverallQuality, 0, 'f', 2)
          );
          

          I suspect you meant:

          strText = QCoreApplication::translate(
              "LiveEngine",
              "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
              "IDS_LOG_REGISTERRESULTS", 
              static_cast<int>(lfi.m_vStars.size())
          )
          .arg(QString::fromWCharArray(strName)) ///< Extra `)` here.
          .arg(lfi.m_fFWHM, 0, 'f', 2)
          .arg(lfi.m_fOverallQuality, 0, 'f', 2); ///< One less `)` here.
          

          Cheers.

          P Offline
          P Offline
          Perdrix
          wrote on 29 Apr 2023, 16:18 last edited by Perdrix
          #4

          @Paul-Colby Well darn it! How did I miss that!

          BUT after I changed it to

          			strText = QCoreApplication::translate(
          				"LiveEngine",
          				"Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
          				"IDS_LOG_REGISTERRESULTS",
          				static_cast<int>(lfi.m_vStars.size())
          			)
          				.arg(QString::fromWCharArray(strName))
          				.arg(lfi.m_fFWHM, 0, 'f', 2)
          				.arg(lfi.m_fOverallQuality, 0, 'f', 2); 
          

          and running lupdate the .ts file still has no entry for that translation :(

          P P 2 Replies Last reply 3 May 2023, 00:08
          0
          • P Perdrix
            29 Apr 2023, 16:18

            @Paul-Colby Well darn it! How did I miss that!

            BUT after I changed it to

            			strText = QCoreApplication::translate(
            				"LiveEngine",
            				"Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
            				"IDS_LOG_REGISTERRESULTS",
            				static_cast<int>(lfi.m_vStars.size())
            			)
            				.arg(QString::fromWCharArray(strName))
            				.arg(lfi.m_fFWHM, 0, 'f', 2)
            				.arg(lfi.m_fOverallQuality, 0, 'f', 2); 
            

            and running lupdate the .ts file still has no entry for that translation :(

            P Offline
            P Offline
            Perdrix
            wrote on 3 May 2023, 00:08 last edited by
            #5

            Can anyone cast some light on this problem - its really quite an issue for me.

            1 Reply Last reply
            0
            • P Perdrix
              29 Apr 2023, 16:18

              @Paul-Colby Well darn it! How did I miss that!

              BUT after I changed it to

              			strText = QCoreApplication::translate(
              				"LiveEngine",
              				"Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
              				"IDS_LOG_REGISTERRESULTS",
              				static_cast<int>(lfi.m_vStars.size())
              			)
              				.arg(QString::fromWCharArray(strName))
              				.arg(lfi.m_fFWHM, 0, 'f', 2)
              				.arg(lfi.m_fOverallQuality, 0, 'f', 2); 
              

              and running lupdate the .ts file still has no entry for that translation :(

              P Offline
              P Offline
              Paul Colby
              wrote on 3 May 2023, 01:21 last edited by
              #6

              @Perdrix said in LUpdate not adding entry to .ts file:

              and running lupdate the .ts file still has no entry for that translation :(

              Interesting. This looks like a pretty clear lupdate bug to me, where lupdate is failing on the cast of the n argument. For example, this doesn't work for me:

                  auto strText = QCoreApplication::translate(
                                "LiveEngine",
                                "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
                                "IDS_LOG_REGISTERRESULTS",
                                static_cast<int>(123) ///< This breaks lupdate?
                                )
                                .arg(QString::fromWCharArray(nullptr))
                                .arg(0.01, 0, 'f', 2)
                                .arg(0.02, 0, 'f', 2);
              

              And this does't work either:

                  auto strText = QCoreApplication::translate(
                                "LiveEngine",
                                "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
                                "IDS_LOG_REGISTERRESULTS",
                                (int)123 ///< This breaks lupdate also?
                                )
                                .arg(QString::fromWCharArray(nullptr))
                                .arg(0.01, 0, 'f', 2)
                                .arg(0.02, 0, 'f', 2);
              

              But this works fine (for lupdate ... I wouldn't execute the code itself ;)

                  auto strText = QCoreApplication::translate(
                                "LiveEngine",
                                "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
                                "IDS_LOG_REGISTERRESULTS",
                                123
                                )
                                .arg(QString::fromWCharArray(nullptr))
                                .arg(0.01, 0, 'f', 2)
                                .arg(0.02, 0, 'f', 2);
              

              And this works also:

                  const int size = 123;
                  auto strText = QCoreApplication::translate(
                                "LiveEngine",
                                "Image %1 registered: %n star(s) detected - FWHM = %2 - Score = %3\n",
                                "IDS_LOG_REGISTERRESULTS",
                                size
                                )
                                .arg(QString::fromWCharArray(nullptr))
                                .arg(0.01, 0, 'f', 2)
                                .arg(0.02, 0, 'f', 2);
              

              So I would suggest you convert your lfi.m_vStars.size() to int as a separate statement, and then report this as a bug over at https://bugreports.qt.io/ (or I can report it, if you don't get around to it)

              Cheers.

              1 Reply Last reply
              0

              6/6

              3 May 2023, 01:21

              • Login

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