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

Support template strings for translation in QML files

XMLWordPrintable

    • All

      It would be nice to be able to write translatable string using template literals in QML files like

      import QtQuick
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          Column {
              Text {
                  text: qsTr("Width: %1 Height: %2").arg(root.width).arg(root.height)
              }
              Text {
                  text: qsTr(`Width: ${root.width} Height: ${root.height}`)
              }
          }
      }
      

      This is currently not possible since the template string is evaluated by the JS interpreter.
      We need to research how we can support this.

      One possibility is the introduction of a new tag function like explained in https://bugreports.qt.io/browse/QTBUG-127527?focusedId=836985&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-836985

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

            kkohne Kai Köhne
            jbornema Joerg Bornemann
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes