<div dir="ltr">Hello all,<div><br></div><div>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:</div><div><br></div><div>ui file:</div><div>=========================</div><div><div><?xml version="1.0" encoding="UTF-8"?></div><div><ui version="4.0"></div><div> <class>MainWindow</class></div><div> <widget class="QMainWindow" name="MainWindow"></div><div>  <property name="geometry"></div><div>   <rect></div><div>    <x>0</x></div><div>    <y>0</y></div><div>    <width>800</width></div><div>    <height>600</height></div><div>   </rect></div><div>  </property></div><div>  <property name="windowTitle"></div><div>   <string>MainWindow</string></div><div>  </property></div><div>  <widget class="QWidget" name="centralwidget"></div><div>   <widget class="QPushButton" name="pushButton"></div><div>    <property name="geometry"></div><div>     <rect></div><div>      <x>90</x></div><div>      <y>80</y></div><div>      <width>75</width></div><div>      <height>23</height></div><div>     </rect></div><div>    </property></div><div>    <property name="text"></div><div>     <string>菜单</string></div><div>    </property></div><div>   </widget></div><div>   <widget class="QPushButton" name="pushButton_2"></div><div>    <property name="geometry"></div><div>     <rect></div><div>      <x>280</x></div><div>      <y>80</y></div><div>      <width>75</width></div><div>      <height>23</height></div><div>     </rect></div><div>    </property></div><div>    <property name="text"></div><div>     <string>PushButton</string></div><div>    </property></div><div>   </widget></div><div>   <widget class="QLabel" name="label"></div><div>    <property name="geometry"></div><div>     <rect></div><div>      <x>200</x></div><div>      <y>80</y></div><div>      <width>54</width></div><div>      <height>12</height></div><div>     </rect></div><div>    </property></div><div>    <property name="text"></div><div>     <string>标签</string></div><div>    </property></div><div>   </widget></div><div>  </widget></div><div>  <widget class="QMenuBar" name="menubar"></div><div>   <property name="geometry"></div><div>    <rect></div><div>     <x>0</x></div><div>     <y>0</y></div><div>     <width>800</width></div><div>     <height>23</height></div><div>    </rect></div><div>   </property></div><div>  </widget></div><div>  <widget class="QStatusBar" name="statusbar"/></div><div> </widget></div><div> <resources/></div><div> <connections/></div><div></ui></div></div><div>=========================</div><div><div><br></div><div>pylupdate on the ui file will give:</div><div>=========================</div><div><div><?xml version="1.0" encoding="utf-8"?></div><div><!DOCTYPE TS><TS version="2.0"></div><div><context></div><div>    <name>MainWindow</name></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="14"/></div><div>        <source>MainWindow</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message encoding="UTF-8"></div><div>        <location filename="mainwindow.ui" line="27"/></div><div>        <source>菜单</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="40"/></div><div>        <source>PushButton</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message encoding="UTF-8"></div><div>        <location filename="mainwindow.ui" line="53"/></div><div>        <source>标签</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div></context></div><div></TS></div></div><div>=========================</div><div>which is OK as far as I can see. Then translate the ts in Qt Lingust5.7.0 into:</div><div>=========================</div><div><div><?xml version="1.0" encoding="utf-8"?></div><div><!DOCTYPE TS></div><div><TS version="2.1" language="en" sourcelanguage="zh"></div><div><context></div><div>    <name>MainWindow</name></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="14"/></div><div>        <source>MainWindow</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="27"/></div><div>        <source>菜单</source></div><div>        <translation>menu</translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="40"/></div><div>        <source>PushButton</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="53"/></div><div>        <source>标签</source></div><div>        <translation>lable</translation></div><div>    </message></div><div></context></div><div></TS></div></div><div>=========================</div><div><br></div><div>Then pyludate the .ts file again will discard the translated entries with Chinese source:</div><div>=========================</div><div><div><?xml version="1.0" encoding="utf-8"?></div><div><!DOCTYPE TS><TS version="2.0" language="en" sourcelanguage="zh"></div><div><context></div><div>    <name>MainWindow</name></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="14"/></div><div>        <source>MainWindow</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="53"/></div><div>        <source>??</source></div><div>        <translation type="obsolete">lable</translation></div><div>    </message></div><div>    <message></div><div>        <location filename="mainwindow.ui" line="40"/></div><div>        <source>PushButton</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message encoding="UTF-8"></div><div>        <location filename="mainwindow.ui" line="27"/></div><div>        <source>菜单</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div>    <message encoding="UTF-8"></div><div>        <location filename="mainwindow.ui" line="53"/></div><div>        <source>标签</source></div><div>        <translation type="unfinished"></translation></div><div>    </message></div><div></context></div><div></TS></div></div><div>=========================</div><div>As you can see, the "menu" translation is totally discarded while the source of the "lable" translation is recognized as "??"...</div><div><br></div><div>I launch the pyludate in msys2 env while the Python is native Windows program and PyQt5 is installed by pip, not in msys2 env.</div><div><br></div><div>This problem only happens when launching pylupdate in msys2. In cmd console, things seem to be fine.</div><div><br></div><div>How could I cope with this problem?</div><div><br></div>-- <br><div class="gmail_signature">Cheers,<br>Grissiom</div>
</div></div>