Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2562

Lupdate doesn't recognize python u-strings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.6.1
    • Tooling
    • None
    • Python 3.12
    • Windows

      Pyside6-lupdate does not pick up python unicode strings.
      This is problematic because pyside6-uic generates unicode strings from .ui files.
      As a result, none of the uic-generated code is translatable without additional editing.

      Minimal example .ui:

      <?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
       <class>Foo</class>
       <widget class="QWidget" name="Foo">
        <property name="windowTitle">
         <string>FooTitle</string>
        </property>
       </widget>
       <resources/>
       <connections/>
      </ui> 

      Compilation with pyside6-uic creates a python file including the following translation function:

      def retranslateUi(self, Foo):
          Foo.setWindowTitle(QCoreApplication.translate("Foo", u"FooTitle", None)) 

      Running this file through pyside6-lupdate results in an empty .ts file.

       

      After changing u"FooTitle" into a standard python string "FooTitle", lupdate recognizes the string and generates a valid translation file:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE TS>
      <TS version="2.1">
      <context>
          <name>Foo</name>
          <message>
              <location filename="ui_untitled.py" line="31"/>
              <source>FooTitle</source>
              <translation type="unfinished"></translation>
          </message>
      </context>
      </TS> 

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

            crmaurei Cristian Maureira-Fredes
            maxxpower Markus Fleischhacker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes