<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr"><div>Hi, Phil.</div><div><br></div><div>No, you get the same result than me<br></div><div><br></div><div><?xml version="1.0" encoding="utf-8"?><br><!DOCTYPE TS><br><TS version="2.1"><br>...<br> <b> <context><br> <name>TranslatedClass</name><br> <message><br> <location filename="translated_library.py" line="7" /><br> <source>context</source><br> <comment>This is the text to translate, not the comment</comment><br> <translation type="unfinished" /><br> </message><br> </context><br> <context></b></div><div><b>...</b><br> <br></div><div>This entries is not fine detected, the context is bad detected as the translated text, and the text to translate as the comment to translator<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El sáb, 22 jun 2024 a las 15:38, Phil Thompson (<<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 19/06/2024 15:51, Juan José Gómez Romera wrote:<br>
> I have a application with international support. This application is a<br>
> python graphical interface with class derived of QObject, and other <br>
> without<br>
> no qt inheritance. The application can use pyqt5 or pyqt6 indistinctly. <br>
> The<br>
> problem is pylupdate6 is unable to detect fine the text using the<br>
> QtWidget.QApplication.translate short name... I post a minimum example<br>
> <br>
> qt.py<br>
> <br>
>> #!/usr/bin/python3<br>
>> # -*- coding: utf-8 -*-<br>
>> <br>
>> try:<br>
>> from PyQt6 import QtWidgets<br>
>> except ImportError:<br>
>> from PyQt5 import QtWidgets<br>
>> <br>
>> # short name used in non QObject instances to apply translation<br>
>> tr = QtWidgets.QApplication.translate<br>
>> <br>
> <br>
> translated_library.py<br>
> <br>
>> #!/usr/bin/python3<br>
>> # -*- coding: utf-8 -*-<br>
>> <br>
>> from qt import QtWidgets, tr<br>
>> <br>
>> class TranslatedClass():<br>
>> title = tr("context", "This is the text to translate, not the <br>
>> comment")<br>
>> name = QtWidgets.QApplication.translate("context", "This text is<br>
>> detected fine by pylupdate6")<br>
>> <br>
>> class QtRelatedClass(QtWidgets.QDialog):<br>
>> """Its translation are correctly detect by pylupdate6"""<br>
>> def __init__(self):<br>
>> super().__init__(self)<br>
>> <a href="http://self.name" rel="noreferrer" target="_blank">self.name</a> = <a href="http://self.tr" rel="noreferrer" target="_blank">self.tr</a>("correctly translated text")<br>
>> <br>
> <br>
> The example_es.ts is the generated ts file by pylupdate, where the <br>
> title<br>
> attribute in non qt class are not fine detected.<br>
> <br>
> Name attribute is detected fine, but i would use a short alias to avoid<br>
> write so long QtWidgets.QApplication.translate...<br>
> <br>
> Thanks for your help<br>
<br>
Works fine for me. Attached is the output I get of running...<br>
<br>
pylupdate6 --ts test.ts translated_library.py<br>
<br>
Phil</blockquote></div>
</div></div>