Discrepancy between pylupdate and Qt Linguist
Phil Thompson
phil at riverbankcomputing.com
Sat Jul 12 13:19:27 BST 2025
On 12/07/2025 12:58, Detlev Offenbach wrote:
> 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.
Would 'level=1' passed to indent() do the same thing? It might be easier
to send me pylupdate and Linguist versions of the same .ts file so I can
see exactly what you mean.
Phil
More information about the PyQt
mailing list