https://bugs.llvm.org/show_bug.cgi?id=48539
Add support for Qt Translator Comments to reflow
When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.
Differential D93490
[clang-format] PR48539 ReflowComments breaks Qt translation comments MyDeveloperDay on Dec 17 2020, 1:20 PM. Authored by
Details https://bugs.llvm.org/show_bug.cgi?id=48539 Add support for Qt Translator Comments to reflow When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.
Diff Detail
Event TimelineComment Actions I don't know if this really fixes the problem. From the Docs:
With the example //~ loc-layout_id foo_dialog //~ loc-blank False //~ magic-stuff This might mean something magic. So I would say breaking the ~ comment is a no go, but I would have to test it. (Which I can do next week.) Comment Actions Maybe @JVApen can help as they logged https://bugs.llvm.org/show_bug.cgi?id=48539 I'm not a Qt developer so I can't really comment beyond fixing what was in the bug rpeort Comment Actions We actually only use //: in our code, I found the others when looking at the docs. Maybe it's better to skip //~ and add a to-do with the open question if we even can correctly reflow this? Comment Actions So, I've tested a bit: //= Die ID //~ foo bar //~ EinWort Ein langer Text der fortgesetzt wird //: Dies ist ein langer Kommentar //: der umgebrochen wird tr("Foo"); Results in <message id="Die ID"> <location filename="wid.cpp" line="9"/> <source>Foo</source> <extracomment>Dies ist ein langer Kommentar der umgebrochen wird</extracomment> <translation type="unfinished"></translation> <extra-EinWort>Ein langer Text der fortgesetzt wird</extra-EinWort> <extra-foo>bar</extra-foo> </message> And breaking //= or //~ as followed //= Die //= ID //~ foo bar //~ EinWort Ein langer Text der //~ fortgesetzt wird //: Dies ist ein langer Kommentar //: der umgebrochen wird tr("Foo"); changes the result <message id="ID"> <location filename="wid.cpp" line="11"/> <source>Foo</source> <extracomment>Dies ist ein langer Kommentar der umgebrochen wird</extracomment> <translation type="unfinished"></translation> <extra-EinWort>Ein langer Text der</extra-EinWort> <extra-foo>bar</extra-foo> <extra-fortgesetzt>wird</extra-fortgesetzt> </message> So my conclusion is //: can and should be wrapped like in this patch, but //= and //~ should not be touched anyhow, this can be accomplished with the CommentPragmas Setting. Comment Actions Wouldn't it make sense to explicitly document that //= and //~ are not put in here as reflowing them results in wrong results? Comment Actions This looks good to me. I think this would fit in a separate change which would also modify the documentation of CommentPragmas, so that who ever needs it could set that accordingly. I'm currently trying to fix a misformating with AlignConsecutiveDeclarations with Qts emit, maybe there should be at Qt-Mode or something similar? As far as I can see there are some code paths to accommodate Qt. |