HTML `& quot; ` entity in Qt designer UI file causes translation to not be used

Alvin Wong alvin at alvinhc.com
Wed Jun 30 10:49:34 BST 2021


I made a merge request on this:

https://invent.kde.org/sdk/kde-dev-scripts/-/merge_requests/15


Alvin Wong 於 24/6/2021 22:19 寫道:
> Hi,
>
> Some of the formatting have been mixed up. Please check 
> https://invent.kde.org/-/snippets/1730 for a clearer version of the 
> message.
>
> Best Regards,
>
> Alvin Wong
>
> Alvin Wong 於 24/6/2021 22:06 寫道:
>> Hi,
>>
>> When I was checking the translations for Krita, I noticed some UI 
>> items not using the translation even though they are available and 
>> translated in the PO files. On further investigation I found out it 
>> is due to the HTML """ entity in the strings.
>>
>> For example, the string in 
>> `libs/ui/forms/wdgperformancesettings.ui:552`[1] contains 
>> `"`, which is output as `"` inside a string literal by 
>> `uic`. The full line in the generated header file is as follows:
>>
>> chkTransformToolForceLodMode->setToolTip(tr2i18n("<html><head/><body><p>The 
>> transform tool preview will always use instant preview, even if 
>> instant preview is disabled in the "View" 
>> menu</p></body></html>", nullptr));
>>
>> In the PO file [2] however, the extracted string looks like this:
>>
>>     #. i18n: ectx: property (toolTip), widget (QCheckBox, 
>> chkTransformToolForceLodMode)
>>     #: libs/ui/forms/wdgperformancesettings.ui:552
>>     #, kde-format
>>     msgid ""
>>     "<html><head/><body><p>The transform tool preview will always use 
>> instant "
>>     "preview, even if instant preview is disabled in the \"View\" 
>> menu</p></"
>>     "body></html>"
>>     msgstr ""
>> "<html><head/><body><p>強制變形工具使用即時預覽,無視「顯示」選單中停用即時預" 
>>
>>     "覽的設定</p></body></html>"
>>
>> Notice that the double-escaped `&quot;` gets transformed into `"` 
>> (double quote) instead of `"`, making the string not match and 
>> causing the translation to not be used. Indeed, if I replace the 
>> `&quot;` in the UI file with just `"` (double quote), the 
>> translated string shows up properly.
>>
>> We use the Qt designer tool and I believe that the entity 
>> `&quot;` is generated by said tool. Shall we be manually 
>> replacing these entities in our UI files, or is it a bug in the POT 
>> extraction process that needs fixing?
>>
>> Best Regards,
>>
>> Alvin Wong
>>
>> [1]: 
>> https://invent.kde.org/graphics/krita/-/blob/eb72dd1b857e1daf7316175dec5d7738b00aef23/libs/ui/forms/wdgperformancesettings.ui#L552
>> [2]: 
>> https://websvn.kde.org/*checkout*/trunk/l10n-kf5/zh_TW/messages/krita/krita.po?revision=1603060&content-type=text%2Fplain
>>


More information about the kde-i18n-doc mailing list