Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113354

LUpdate not adding entry to .ts file

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 6.4.0, 6.5.0
    • Tools: Linguist
    • None

    Description

      This stems from an entry in the Qt forum:
      LUpdate not adding entry to .ts file

      The gist is, for the following code:

      int main() {
          auto strText = QCoreApplication::translate("context", "%n cats", nullptr, 123);
          auto strText = QCoreApplication::translate("context", "%n dogs", nullptr, (int)123);
          auto strText = QCoreApplication::translate("context", "%n monkeys", nullptr, static_cast<int>(123));
      }
      

      Only one translation is produced:

      $ ~/dev/qt/dev-native/qtbase/bin/lupdate foo.cpp -ts foo_de.ts
      Updating 'foo_de.ts'...
          Found 1 source text(s) (1 new and 0 already existing)
      

      The content of the .ts file:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE TS>
      <TS version="2.1" language="de_DE">
      <context>
          <name>context</name>
          <message numerus="yes">
              <location filename="foo.cpp" line="2"/>
              <source>%n cats</source>
              <translation type="unfinished">
                  <numerusform></numerusform>
                  <numerusform></numerusform>
              </translation>
          </message>
      </context>
      </TS>
      

      Work-around: store the number in a variable and refer to that:

          int x = static_cast<int>(123);
          auto strText = QCoreApplication::translate("context", "%n monkeys", nullptr, x);
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kkohne Kai Köhne
              perdrix David Partridge
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes