New lines produce fuzzy noise in updated PO files
Original Reporter info from Mantis: dezlov
-
Reporter name: Denis Kozlov
Original Reporter info from Mantis: dezlov
- Reporter name: Denis Kozlov
Description:
Certain new line styles cause false fuzzy entries added to updated PO files, accumulating noise for every update.
The conditions are:
- Resource strings contain non system default line styles (system - is where we compile project and update PO files).
- PO files that are being updated have non-empty translation in entries that contain new line characters.
The root cause seems to be in TPOFile.UpdateItem, where CompareMultilinedStrings and SkipLineEndings are mismatching some new line styles. I have only investigated PO files, so don't know if MO files are affected too.
In the example (in additional info), notice the accumulation of fuzzy msgid entries. This test was on Windows, so on other platforms probably different new line styles will get affected. So far the best workaround seems to be using only the system default new line style in resource strings, i.e. sLineBreak or LineEnding.
If it's not worth fixing, perhaps it should at least be mentioned in the documentation.
Additional information:
For example, if we have the following resource strings (using LF [0x0A] and CR [0x0D], because of how Mantis treats hash symbol):
RS1 = 'A' + CRLF + CRLF + 'B'; // Windows style
RS2 = 'A' + LFCR + LFCR + 'B';
RS3 = 'A' + CR + CR + 'B'; // Mac OS style up to v9
RS4 = 'A' + LF + LF + 'B'; // Unix style
(http://en.wikipedia.org/wiki/Newline#Representations)
Create a copy of auto-generated PO file (e.g. name it project1.en.po) and fill with dummy translations:
-------------------------
#: unit1.rs1
msgid ""
"A\n"
"\n"
"B\n"
msgstr "a"
#: unit1.rs2
msgid ""
"A\n"
"\n"
"\n"
"B\n"
msgstr "b"
#: unit1.rs3
msgid ""
"A\n"
"\n"
"B\n"
msgstr "c"
#: unit1.rs4
msgid ""
"A\n"
"\n"
"B\n"
msgstr "d"
-------------------------
Now, force update of PO files a couple of times by adding or changing another resource string, the effect is:
-------------------------
#: unit1.rs1
msgid ""
"A\n"
"\n"
"B\n"
msgstr "a"
#: unit1.rs2
msgid ""
"A\n"
"\n"
"\n"
"B\n"
msgstr "b"
#: unit1.rs3
#, fuzzy
#| msgid ""
#| "A\n"
#| "\n"
#| "B\n"
#| "A\n"
#| "\n"
#| "B\n"
#| "A\n"
#| "\n"
#| "B\n"
msgid ""
"A\n"
"\n"
"B\n"
msgstr "c"
#: unit1.rs4
msgid ""
"A\n"
"\n"
"B\n"
msgstr "d"
-------------------------
Mantis conversion info:
- Mantis ID: 26616
- Build: Lazarus 1.2.4 r45510 FPC 2.6.4
- Platform: Windows
- Version: 1.2.4
- Fixed in version: 1.4
- Fixed in revision: 46076 (#6cbf4971)
- Monitored by: » dezlov (Denis Kozlov)