https://bugs.kde.org/show_bug.cgi?id=493709
Bug ID: 493709 Summary: Alternate (previous) translation doesn’t handle diff of messages with msgctxt properly Classification: Applications Product: lokalize Version: unspecified Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: sdepi...@gmail.com Reporter: k...@huftis.org CC: aa...@kde.org, sha...@ukr.net Target Milestone: --- SUMMARY In the diff view showing the previous msgid (Alternate Translations pane), the msgctxt is merged with the msgid, resulting in a wrong diff. The first word in each string is shown to belong to the msgctxt, resulting in very long/confusing diffs. This is easiest to show with an example: #, fuzzy #| msgctxt "@windowtitle" #| msgid "that was a test" msgctxt "@windowtitle" msgid "this is a test" msgstr "dette er ein test" The diff view in the alternative translation pane says that the change is @windowtitlethat was → @windowtitlethis is But the correct diff is that is → this is The reason for the bug is the following lines in alttransview.cpp: prevMsgId.replace(QStringLiteral("\n"), QString()); currentMsgId.replace(QStringLiteral("\n"), QString()); But in each of the two variables, the original string is stored as: msgctxt + "\n" + msgid And the string replacement removes all "\n" characters. The explanation is: // Messages have arbitrary word wrapping, which should // not affect the diff. So we remove any word wrapping // newlines. (Note that this does not remove manual \n // characters used in the messages.) This makes sense, but unfortunately, it also removes the separator between the msgctxt and the msgid. Now this is easy to fix for the currentMsgId variable. Just do the "\n" replacement *before* prefixing the msgctxt, not after. E.g., change: QString currentMsgId = contextWithNewline + source.string; to just QString currentMsgId = source.string; Then do the "\n" replacement on currentMsgId, and finally create a: QString currentMsg = contextWithNewline + currentMsgId; (And use currentMsg instead of currentMsgId in the userVisibleWordDiff() call below.) But this doesn’t work for prevMsgId, which is defined as: QString prevMsgId = entry.source.string; It *already* includes the msgctxt (followed by "\n" followed by the msgid). The entry is an AltTrans object, and the entry.source is a CatalogString object. But I can’t seem to figure out where the code is that defines the content of the entry.source.string or how to instead extract the msgctxt and the msgid separately. So I’m adding this bug report here. Hopefully someone more familiar with C++ / the Lokalize code base can figure this out. -- You are receiving this mail because: You are watching all bug changes.