[PyQt] pylupdate failed to update the .ts file that the source string is non-ACSII chars

Grissiom chaos.proton at gmail.com
Sun Oct 23 14:25:18 BST 2016


Hello all,

I'm developing an application with PyQt5 and I found a bug that if the
original UI is not English, pyludate will discard any translated entries in
the .ts file. Here is an example:

ui file:
=========================
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>90</x>
      <y>80</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>菜单</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>80</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>PushButton</string>
    </property>
   </widget>
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>200</x>
      <y>80</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>标签</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>800</width>
     <height>23</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>
=========================

pylupdate on the ui file will give:
=========================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
    <name>MainWindow</name>
    <message>
        <location filename="mainwindow.ui" line="14"/>
        <source>MainWindow</source>
        <translation type="unfinished"></translation>
    </message>
    <message encoding="UTF-8">
        <location filename="mainwindow.ui" line="27"/>
        <source>菜单</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="40"/>
        <source>PushButton</source>
        <translation type="unfinished"></translation>
    </message>
    <message encoding="UTF-8">
        <location filename="mainwindow.ui" line="53"/>
        <source>标签</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>
=========================
which is OK as far as I can see. Then translate the ts in Qt Lingust5.7.0
into:
=========================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en" sourcelanguage="zh">
<context>
    <name>MainWindow</name>
    <message>
        <location filename="mainwindow.ui" line="14"/>
        <source>MainWindow</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="27"/>
        <source>菜单</source>
        <translation>menu</translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="40"/>
        <source>PushButton</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="53"/>
        <source>标签</source>
        <translation>lable</translation>
    </message>
</context>
</TS>
=========================

Then pyludate the .ts file again will discard the translated entries with
Chinese source:
=========================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0" language="en" sourcelanguage="zh">
<context>
    <name>MainWindow</name>
    <message>
        <location filename="mainwindow.ui" line="14"/>
        <source>MainWindow</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="53"/>
        <source>??</source>
        <translation type="obsolete">lable</translation>
    </message>
    <message>
        <location filename="mainwindow.ui" line="40"/>
        <source>PushButton</source>
        <translation type="unfinished"></translation>
    </message>
    <message encoding="UTF-8">
        <location filename="mainwindow.ui" line="27"/>
        <source>菜单</source>
        <translation type="unfinished"></translation>
    </message>
    <message encoding="UTF-8">
        <location filename="mainwindow.ui" line="53"/>
        <source>标签</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>
=========================
As you can see, the "menu" translation is totally discarded while the
source of the "lable" translation is recognized as "??"...

I launch the pyludate in msys2 env while the Python is native Windows
program and PyQt5 is installed by pip, not in msys2 env.

This problem only happens when launching pylupdate in msys2. In cmd
console, things seem to be fine.

How could I cope with this problem?

-- 
Cheers,
Grissiom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161023/66d1b6eb/attachment.html>


More information about the PyQt mailing list