Bug 357274

Summary: Semantic tags not respected in nested xi18nc calls
Product: [Frameworks and Libraries] frameworks-ki18n Reporter: Elvis Angelaccio <elvis.angelaccio>
Component: generalAssignee: Chusslove Illich <caslav.ilic>
Status: RESOLVED NOT A BUG    
Severity: normal CC: kdelibs-bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Results of nesting xi18nc calls with different context

Description Elvis Angelaccio 2015-12-28 18:27:09 UTC
Similar to bug #357273, but now the two nested xi18n calls have differenct contexts: https://paste.kde.org/poeleukgb

As you can see in the attached screenshot, the semantic tag in the nested xi18nc() is not respected.

Reproducible: Always
Comment 1 Elvis Angelaccio 2015-12-28 18:27:44 UTC
Created attachment 96337 [details]
Results of nesting xi18nc calls with different context
Comment 2 Chusslove Illich 2015-12-29 13:22:22 UTC
*** Bug 357273 has been marked as a duplicate of this bug. ***
Comment 3 Chusslove Illich 2015-12-29 13:24:47 UTC
xi18n* call return a QString, and QString as argument to an *xi18n* call has to be escaped for XML, as it could be anything. For example, it could be a file path which happens to have something looking like a tag in it. So this behavior is as expected.

Instead, kxi18n* calls should be used for nesting. These return KLocalizedString, for which it is guaranteed that what looks like markup really is markup (as consequence of escaping any other argument type).

The section in documentation that talks about this:

http://api.kde.org/frameworks-api/frameworks5-apidocs/ki18n/html/prg_guide.html#kuit_escape
Comment 4 Elvis Angelaccio 2015-12-29 13:59:41 UTC
Thanks for the explanation :)
Unfortunately is not trivial to refactor existing code to support KLocalizedString. I guess I will simply avoid to use markup in the nested translated messages...