Fwd: Issue with translation detected by pylupdate6
Juan José Gómez Romera
jjgomera at gmail.com
Sun Jun 23 06:27:05 BST 2024
Hi, Phil.
No, you get the same result than me
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
...
* <context> <name>TranslatedClass</name> <message> <location
filename="translated_library.py" line="7" /> <source>context</source>
<comment>This is the text to translate, not the comment</comment>
<translation type="unfinished" /> </message> </context> <context>*
*...*
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
El sáb, 22 jun 2024 a las 15:38, Phil Thompson (<phil at riverbankcomputing.com>)
escribió:
> On 19/06/2024 15:51, Juan José Gómez Romera wrote:
> > I have a application with international support. This application is a
> > python graphical interface with class derived of QObject, and other
> > without
> > no qt inheritance. The application can use pyqt5 or pyqt6 indistinctly.
> > The
> > problem is pylupdate6 is unable to detect fine the text using the
> > QtWidget.QApplication.translate short name... I post a minimum example
> >
> > qt.py
> >
> >> #!/usr/bin/python3
> >> # -*- coding: utf-8 -*-
> >>
> >> try:
> >> from PyQt6 import QtWidgets
> >> except ImportError:
> >> from PyQt5 import QtWidgets
> >>
> >> # short name used in non QObject instances to apply translation
> >> tr = QtWidgets.QApplication.translate
> >>
> >
> > translated_library.py
> >
> >> #!/usr/bin/python3
> >> # -*- coding: utf-8 -*-
> >>
> >> from qt import QtWidgets, tr
> >>
> >> class TranslatedClass():
> >> title = tr("context", "This is the text to translate, not the
> >> comment")
> >> name = QtWidgets.QApplication.translate("context", "This text is
> >> detected fine by pylupdate6")
> >>
> >> class QtRelatedClass(QtWidgets.QDialog):
> >> """Its translation are correctly detect by pylupdate6"""
> >> def __init__(self):
> >> super().__init__(self)
> >> self.name = self.tr("correctly translated text")
> >>
> >
> > The example_es.ts is the generated ts file by pylupdate, where the
> > title
> > attribute in non qt class are not fine detected.
> >
> > Name attribute is detected fine, but i would use a short alias to avoid
> > write so long QtWidgets.QApplication.translate...
> >
> > Thanks for your help
>
> Works fine for me. Attached is the output I get of running...
>
> pylupdate6 --ts test.ts translated_library.py
>
> Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240623/ed49c0ed/attachment-0001.htm>
More information about the PyQt
mailing list