Discrepancy between pylupdate and Qt Linguist
Detlev Offenbach
detlev at die-offenbachs.de
Sat Jul 12 12:58:46 BST 2025
Am 12.07.25 um 11:43 schrieb Phil Thompson:
> On 12/07/2025 10:40, Detlev Offenbach wrote:
>> Am 12.07.25 um 11:30 schrieb Phil Thompson:
>>> On 12/07/2025 10:22, Detlev Offenbach wrote:
>>>> Hi Phil,
>>>>
>>>> I just tried the new pylupdate (actually just translation_file.py) and
>>>> must report, that the file generated by pylupdate and Qt linguist are
>>>> still different. pylupdate indents all context elements by 4 spaces
>>>> whereas Qt linguist does not indent them at all.
>>>>
>>>> Would it be possible to align the bahavior of pylupdate with Qt
>>>> linguist?
>>>
>>> So Qt Linguist is inconsistent in its indentation?
>> Indeed it is. I tested it all the way back to Qt 6.2.x.
>>>
>>> It would require indenting the file "manually". At the moment it
>>> uses...
>>>
>>> https://docs.python.org/3.13/library/xml.etree.elementtree.html#xml.etree.ElementTree.indent
>>>
>> Maybe indenting just the context_el with this method as if it were a
>> root element and then write the top level stuff manually with zero
>> indentation. Unfortunately I am not familiar with ElementTree to
>> change this myself.
>
> I'm not going to put effort into trying to match what is effectively a
> bug in Linguist.
It is not a bug. Indentation is only used to pretty print the file. The
XML would still be valid without any indentation at all. Nevertheless, I
put some (little ) effort into matching the pylupdate output. Please
find the diff against the original (i.e. current stable PyQt 6.9.1)
translation_file.py attached. I hope you will include it in PyQt 6.9.2.
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: translation_file.py.diff
Type: text/x-patch
Size: 1186 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20250712/ebb0532a/attachment.bin>
More information about the PyQt
mailing list