[Development] QtCS2019 Notes: Clang-based cpp parser for lupdate

Kai Pastor, DG0YT dg0yt at darc.de
Fri Nov 22 21:25:01 CET 2019

Am 22.11.19 um 17:03 schrieb Kai Köhne:
>> From: Development<development-bounces at qt-project.org>  On Behalf Of
>> Joerg Bornemann
>> On 11/22/19 7:21 AM, Kai Pastor, DG0YT wrote:
>>> Given the Qt Creator example, would it be feasible to make explicit
>>> declaration of a file's context mandatory, at least for the existing
>>> ("fast") parser? If not mandatory, an explicit declaration could at
>>> least disable all automatic detection for the rest of the file, making
>>> it possible to use modern C++ without surprises.
>> That's certainly a possibility. With an explicit context declaration (that's easy
>> to detect) on file level we can use an even simpler parser/extractor that
>> doesn't have to know much C++ at all.
> Keep in mind that you need this context available both at runtime and
> at lupdate time. That is, the only setup how this IMO would reliably work
> is if  we make the context a part of the tr() call - effectively calling
> QCoreApplication::translate(context, string). This is already possible right
> now.

I admit I didn't think about the runtime perspective. But

     QCoreApplication::translate("Context", string)

is much more verbose then


or, with a declared and defined Context for the translation unit, just


I wonder if an anonymous namespace couldn't be used to safely implement 
the latter for the proposed explicit declaration per translation unit.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20191122/5dde06f6/attachment.html>

More information about the Development mailing list