[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] pylupdate failed to update the .ts file that the source string is non-ACSII chars
From:       Grissiom <chaos.proton () gmail ! com>
Date:       2016-10-23 13:25:18
Message-ID: CALC6sNBtTOvyqf3Pt6vP7=40L_t409Bjbqg81jNwiRP9dcqPeQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

<div dir="ltr">Hello all,<div><br></div><div>I&#39;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>&lt;?xml \
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div>&lt;ui \
version=&quot;4.0&quot;&gt;</div><div>  \
&lt;class&gt;MainWindow&lt;/class&gt;</div><div>  &lt;widget \
class=&quot;QMainWindow&quot; name=&quot;MainWindow&quot;&gt;</div><div>   \
&lt;property name=&quot;geometry&quot;&gt;</div><div>     &lt;rect&gt;</div><div>     \
&lt;x&gt;0&lt;/x&gt;</div><div>      &lt;y&gt;0&lt;/y&gt;</div><div>      \
&lt;width&gt;800&lt;/width&gt;</div><div>      \
&lt;height&gt;600&lt;/height&gt;</div><div>     &lt;/rect&gt;</div><div>   \
&lt;/property&gt;</div><div>   &lt;property \
name=&quot;windowTitle&quot;&gt;</div><div>     \
&lt;string&gt;MainWindow&lt;/string&gt;</div><div>   &lt;/property&gt;</div><div>   \
&lt;widget class=&quot;QWidget&quot; name=&quot;centralwidget&quot;&gt;</div><div>    \
&lt;widget class=&quot;QPushButton&quot; name=&quot;pushButton&quot;&gt;</div><div>   \
&lt;property name=&quot;geometry&quot;&gt;</div><div>        &lt;rect&gt;</div><div>  \
&lt;x&gt;90&lt;/x&gt;</div><div>         &lt;y&gt;80&lt;/y&gt;</div><div>         \
&lt;width&gt;75&lt;/width&gt;</div><div>         \
&lt;height&gt;23&lt;/height&gt;</div><div>        &lt;/rect&gt;</div><div>      \
&lt;/property&gt;</div><div>      &lt;property name=&quot;text&quot;&gt;</div><div>   \
&lt;string&gt;菜单&lt;/string&gt;</div><div>      &lt;/property&gt;</div><div>     \
&lt;/widget&gt;</div><div>     &lt;widget class=&quot;QPushButton&quot; \
name=&quot;pushButton_2&quot;&gt;</div><div>      &lt;property \
name=&quot;geometry&quot;&gt;</div><div>        &lt;rect&gt;</div><div>         \
&lt;x&gt;280&lt;/x&gt;</div><div>         &lt;y&gt;80&lt;/y&gt;</div><div>         \
&lt;width&gt;75&lt;/width&gt;</div><div>         \
&lt;height&gt;23&lt;/height&gt;</div><div>        &lt;/rect&gt;</div><div>      \
&lt;/property&gt;</div><div>      &lt;property name=&quot;text&quot;&gt;</div><div>   \
&lt;string&gt;PushButton&lt;/string&gt;</div><div>      &lt;/property&gt;</div><div>  \
&lt;/widget&gt;</div><div>     &lt;widget class=&quot;QLabel&quot; \
name=&quot;label&quot;&gt;</div><div>      &lt;property \
name=&quot;geometry&quot;&gt;</div><div>        &lt;rect&gt;</div><div>         \
&lt;x&gt;200&lt;/x&gt;</div><div>         &lt;y&gt;80&lt;/y&gt;</div><div>         \
&lt;width&gt;54&lt;/width&gt;</div><div>         \
&lt;height&gt;12&lt;/height&gt;</div><div>        &lt;/rect&gt;</div><div>      \
&lt;/property&gt;</div><div>      &lt;property name=&quot;text&quot;&gt;</div><div>   \
&lt;string&gt; 签&lt;/string&gt;</div><div>      &lt;/property&gt;</div><div>     \
&lt;/widget&gt;</div><div>   &lt;/widget&gt;</div><div>   &lt;widget \
class=&quot;QMenuBar&quot; name=&quot;menubar&quot;&gt;</div><div>     &lt;property \
name=&quot;geometry&quot;&gt;</div><div>      &lt;rect&gt;</div><div>        \
&lt;x&gt;0&lt;/x&gt;</div><div>        &lt;y&gt;0&lt;/y&gt;</div><div>        \
&lt;width&gt;800&lt;/width&gt;</div><div>        \
&lt;height&gt;23&lt;/height&gt;</div><div>      &lt;/rect&gt;</div><div>     \
&lt;/property&gt;</div><div>   &lt;/widget&gt;</div><div>   &lt;widget \
class=&quot;QStatusBar&quot; name=&quot;statusbar&quot;/&gt;</div><div>  \
&lt;/widget&gt;</div><div>  &lt;resources/&gt;</div><div>  \
&lt;connections/&gt;</div><div>&lt;/ui&gt;</div></div><div>=========================</div><div><div><br></div><div>pylupdate \
on the ui file will give:</div><div>=========================</div><div><div>&lt;?xml \
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</div><div>&lt;!DOCTYPE \
TS&gt;&lt;TS version=&quot;2.0&quot;&gt;</div><div>&lt;context&gt;</div><div>      \
&lt;name&gt;MainWindow&lt;/name&gt;</div><div>      &lt;message&gt;</div><div>        \
&lt;location filename=&quot;mainwindow.ui&quot; line=&quot;14&quot;/&gt;</div><div>   \
&lt;source&gt;MainWindow&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message \
encoding=&quot;UTF-8&quot;&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;27&quot;/&gt;</div><div>            \
&lt;source&gt;菜单&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;40&quot;/&gt;</div><div>            \
&lt;source&gt;PushButton&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message \
encoding=&quot;UTF-8&quot;&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;53&quot;/&gt;</div><div>            \
&lt;source&gt; 签&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>&lt;/context&gt;</div><div>&lt;/TS&gt;</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>&lt;?xml \
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</div><div>&lt;!DOCTYPE \
TS&gt;</div><div>&lt;TS version=&quot;2.1&quot; language=&quot;en&quot; \
sourcelanguage=&quot;zh&quot;&gt;</div><div>&lt;context&gt;</div><div>      \
&lt;name&gt;MainWindow&lt;/name&gt;</div><div>      &lt;message&gt;</div><div>        \
&lt;location filename=&quot;mainwindow.ui&quot; line=&quot;14&quot;/&gt;</div><div>   \
&lt;source&gt;MainWindow&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;27&quot;/&gt;</div><div>            \
&lt;source&gt;菜单&lt;/source&gt;</div><div>            \
&lt;translation&gt;menu&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;40&quot;/&gt;</div><div>            \
&lt;source&gt;PushButton&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;53&quot;/&gt;</div><div>            \
&lt;source&gt; 签&lt;/source&gt;</div><div>            \
&lt;translation&gt;lable&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>&lt;/context&gt;</div><div>&lt;/TS&gt;</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>&lt;?xml \
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</div><div>&lt;!DOCTYPE \
TS&gt;&lt;TS version=&quot;2.0&quot; language=&quot;en&quot; \
sourcelanguage=&quot;zh&quot;&gt;</div><div>&lt;context&gt;</div><div>      \
&lt;name&gt;MainWindow&lt;/name&gt;</div><div>      &lt;message&gt;</div><div>        \
&lt;location filename=&quot;mainwindow.ui&quot; line=&quot;14&quot;/&gt;</div><div>   \
&lt;source&gt;MainWindow&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;53&quot;/&gt;</div><div>            \
&lt;source&gt;??&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;obsolete&quot;&gt;lable&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;40&quot;/&gt;</div><div>            \
&lt;source&gt;PushButton&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message \
encoding=&quot;UTF-8&quot;&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;27&quot;/&gt;</div><div>            \
&lt;source&gt;菜单&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>      &lt;message \
encoding=&quot;UTF-8&quot;&gt;</div><div>            &lt;location \
filename=&quot;mainwindow.ui&quot; line=&quot;53&quot;/&gt;</div><div>            \
&lt;source&gt; 签&lt;/source&gt;</div><div>            &lt;translation \
type=&quot;unfinished&quot;&gt;&lt;/translation&gt;</div><div>      \
&lt;/message&gt;</div><div>&lt;/context&gt;</div><div>&lt;/TS&gt;</div></div><div>=========================</div><div>As \
you can see, the &quot;menu&quot; translation is totally discarded while the source \
of the &quot;lable&quot; translation is recognized as \
&quot;??&quot;...</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>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic