<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
Hello there,</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
I discovered a bug in pylupdate5 tool.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
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.</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
Plain example:</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
Python file:</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px">import sys<br>
</span>
<div style="margin: 0px">from PyQt5 import QtCore, QtWidgets<br>
</div>
<div style="margin: 0px">from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget<br>
</div>
<div style="margin: 0px">from PyQt5.QtCore import QSize<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px">class HelloWindow(QMainWindow):<br>
</div>
<div style="margin: 0px"> def __init__(self):<br>
</div>
<div style="margin: 0px"> QMainWindow.__init__(self)<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> self.setMinimumSize(QSize(640, 480))<br>
</div>
<div style="margin: 0px"> self.setWindowTitle(self.tr("Hello world") )<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> centralWidget = QWidget(self)<br>
</div>
<div style="margin: 0px"> self.setCentralWidget(centralWidget)<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> gridLayout = QGridLayout(self)<br>
</div>
<div style="margin: 0px"> centralWidget.setLayout(gridLayout)<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px"> self.dummyvar = ""<br>
</div>
<div style="margin: 0px"> title = QLabel(self.tr("Hello World from PyQt"), self)<br>
</div>
<div style="margin: 0px"> title.setAlignment(QtCore.Qt.AlignCenter)<br>
</div>
<div style="margin: 0px"> gridLayout.addWidget(title, 0, 0)<br>
</div>
<div style="margin: 0px"><br>
</div>
<div style="margin: 0px">if __name__ == "__main__":<br>
</div>
<div style="margin: 0px"> app = QtWidgets.QApplication(sys.argv)<br>
</div>
<div style="margin: 0px"> mainWin = HelloWindow()<br>
</div>
<div style="margin: 0px"> mainWin.show()<br>
</div>
<span style="margin: 0px"> sys.exit( app.exec_() )</span><br>
</div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px">Resulting .ts file:</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px"><?xml version="1.0" encoding="utf-8"?><br>
</span>
<div style="margin: 0px"><!DOCTYPE TS><TS version="2.0"><br>
</div>
<div style="margin: 0px"><context><br>
</div>
<div style="margin: 0px"> <name>HelloWindow</name><br>
</div>
<div style="margin: 0px"> <message><br>
</div>
<div style="margin: 0px"> <location filename="main.py" line="11"/><br>
</div>
<div style="margin: 0px"> <source>Hello world</source><br>
</div>
<div style="margin: 0px"> <translation type="unfinished"></translation><br>
</div>
<div style="margin: 0px"> </message><br>
</div>
<div style="margin: 0px"> <message><br>
</div>
<div style="margin: 0px"> <location filename="main.py" line="21"/><br>
</div>
<div style="margin: 0px"> <source>Hello World from PyQt</source><br>
</div>
<div style="margin: 0px"> <translation type="unfinished"></translation><br>
</div>
<div style="margin: 0px"> </message><br>
</div>
<div style="margin: 0px"></context><br>
</div>
<span style="margin: 0px"></TS></span><br>
</span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px"><br>
</span></span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px"><br>
</span></span></div>
<div style="margin: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; background-color: rgb(255, 255, 255)">
<span style="margin: 0px"><span style="margin: 0px">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.</span></span></div>
<br>
</div>
</body>
</html>