Translated segments that contains line breaks in their source text will become untranslated each time the project is reopened.
I used a text editorto view the project_save.tmx and noticed something might be helpful:
For examle, here is a source segment (en-US) containing a line break:
line1
line2
Translate it and move to another segment (this is important, the "current" segment will not be affected by this problem), then save the project, its corresponding entry in project_save.tmx file looks like:
<tu>
<tuv lang="en-US">
<seg>line1
line2</seg>
</tuv>
<tuv lang="[target lang]" changeid="..." changedate="..." creationid="..." creationdate="...">
<seg>[translation of "line1"]
[translation of "line2"]</seg>
</tuv>
</tu>
Close the project and reopen it, this segment became untranslated, translate it and save the project again, then there will be a new entry in project_save.tmx file looks like:
<tu>
<tuv lang="en-US">
<seg>line1
#xd;
line2</seg>
</tuv>
<tuv lang="[target lang]" changeid="..." changedate="..." creationid="..." creationdate="...">
<seg>[translation of "line1"]
#xd;
[translation of "line2"]</seg>
</tuv>
</tu>
Each time I re-open the projected and re-translate this segment and them save the project, there will be a new entry in tmx with an extra "
" at the end of lines in segment text. It seems that OmegaT does not handle \r in Windows style line breaks correctly.
I have tested it on source files with Windows and Unix line break style , both are the same. I have also tested it on a project containing plain text files only, so it is not caused by a plugin.
All tests is done with latest weekly build (2023-10-09) and on Windows 10 (pro, 22H2, 19045.3448).
I'm pretty sure this problem is caused by
xml.writeCharacters(lineSeparator);inomegat/src/org/omegat/util/TMXWriter2.java. SincelineSeparator = System.lineSeparator()and it will get\r\non Windows.I found a similar question on stackoverflow: https://stackoverflow.com/questions/29675481/xmlstreamwriter-java-8-writecharacters-xd . Hope this helps.
Last edit: Wynn Chen 2023-10-19
Yes,
project_save.tmxis internal format that we can unify line end to be UNIX style.OmegaT 6.1 changes XML engine to Woodstox .
it has an input property P_NORMALIZE_LFS which default is true.
it has output property
this will change XML parser behavior with 6.0 and before.
https://github.com/omegat-org/omegat/pull/780 merged into master.