Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PyQt and Pylupdate5



  • Re: Translation using PyQt and Pylupdate5

    Hello.
    I am trying to create a translation file:

    pylupdate5.py3 untitled.ui -ts zh_FN.ts
    

    I get an error:

    Traceback (most recent call last):
      File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/usr/lib64/python3/site-packages/PyQt5/pylupdate_main.py", line 239, in <module>
        main()
      File "/usr/lib64/python3/site-packages/PyQt5/pylupdate_main.py", line 228, in main
        defaultContext, True)
    UnicodeEncodeError: 'latin-1' codec can't encode characters in position 12-21: ordinal not in range(256)
    

    For the test, I made an empty ui in Designer.
    Wrong encoding again.

    OS Linux
    python 3.7.4
    python3-module-PyQt5 5.11.3

    I am new to Python.
    Sorry if the question is stupid.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show the content of your .ui file ?



  • @SGaist said in PyQt and Pylupdate5:

    Can you show the content of your .ui file ?

    A practically empty sample.

    <?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>491</width>
        <height>323</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralwidget">
       <layout class="QGridLayout" name="gridLayout">
        <item row="0" column="0" colspan="3">
         <widget class="QTextEdit" name="textEdit">
          <property name="html">
           <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
    &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
    p, li { white-space: pre-wrap; }
    &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
    &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Hi, I'm Zhenya.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
          </property>
         </widget>
        </item>
        <item row="1" column="0">
         <widget class="QPushButton" name="pushButton">
          <property name="text">
           <string>PushButton</string>
          </property>
         </widget>
        </item>
        <item row="1" column="1">
         <spacer name="horizontalSpacer">
          <property name="orientation">
           <enum>Qt::Horizontal</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
            <width>292</width>
            <height>20</height>
           </size>
          </property>
         </spacer>
        </item>
        <item row="1" column="2">
         <widget class="QPushButton" name="pushButton_2">
          <property name="text">
           <string>PushButton</string>
          </property>
         </widget>
        </item>
       </layout>
      </widget>
      <widget class="QStatusBar" name="statusbar"/>
     </widget>
     <resources/>
     <connections/>
    </ui>
    


  • Answer.
    The path must not contain non-ascii characters.


  • Lifetime Qt Champion

    Do you mean the path to the file ?


Log in to reply