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

List:       pykde
Subject:    Re: [PyQt] [PYQT5] [Pylupdate5] Bug in pylupdate5: wrong line numeration
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2019-02-19 11:04:41
Message-ID: 96F8D557-B10F-4582-AE09-503ACF391A5F () riverbankcomputing ! com
[Download RAW message or body]

On 15 Feb 2019, at 5:04 am, ?????? ????????? <rk.hh@live.com> wrote:
> 
> Hello there,
> I discovered a bug in pylupdate5 tool.
> Through .ts file generation it sets wrong line numbers for translation strings if \
> there are strings ending with doubled single or double quotes symbol (which is an \
> empty string literal in python) before translated line. Plain example:
> 
> Python file:
> 
> import sys
> from PyQt5 import QtCore, QtWidgets
> from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
> from PyQt5.QtCore import QSize
> 
> class HelloWindow(QMainWindow):
> def __init__(self):
> QMainWindow.__init__(self)
> 
> self.setMinimumSize(QSize(640, 480))
> self.setWindowTitle(self.tr("Hello world") )
> 
> centralWidget = QWidget(self)
> self.setCentralWidget(centralWidget)
> 
> gridLayout = QGridLayout(self)
> centralWidget.setLayout(gridLayout)
> 
> self.dummyvar = ""
> title = QLabel(self.tr("Hello World from PyQt"), self)
> title.setAlignment(QtCore.Qt.AlignCenter)
> gridLayout.addWidget(title, 0, 0)
> 
> if __name__ == "__main__":
> app = QtWidgets.QApplication(sys.argv)
> mainWin = HelloWindow()
> mainWin.show()
> sys.exit( app.exec_() )
> 
> 
> Resulting .ts file:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE TS><TS version="2.0">
> <context>
> <name>HelloWindow</name>
> <message>
> <location filename="main.py" line="11"/>
> <source>Hello world</source>
> <translation type="unfinished"></translation>
> </message>
> <message>
> <location filename="main.py" line="21"/>
> <source>Hello World from PyQt</source>
> <translation type="unfinished"></translation>
> </message>
> </context>
> </TS>
> 
> 
> We can see the string literal on line 11 is defined correctly, but a second \
> translated string on line 20 is defined as it was on line 21 in .ts file. If we \
> remove 19 line with empty string literal assignng (so translated string will be on \
> line 19 instead of 20) and run pylupdate5 again, in resulting .ts file that string \
> will have correct line number 19.

Should be fixed in tonight's PyQt snapshot.

Thanks,
Phil
_______________________________________________
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