Added translate="no" in XLIFF causes merge error

Issue #517 new
x x created an issue

Hello, I have issues when I add translate="no" in XLIFF files.

I created an OmegaT project with the Rainbow "Translation kit". The project folder is attached. In the file omegattmp\source\temp\a.txt.xlf I added a translate="no" attribute on the first <trans-unit> tag. I generated the translated document from OmegaT (an external command is lanched : java -jar rainbow.jar -x TranslationKitPostProcessing ......). But the problem, in the translated txt document (in folder done), 2 lines are missing, there is only the last line.

Rainbow 6.0.28 - OmegaT 3.1.9_04 (last stable)

Comments (4)

  1. YvesS

    The cause of this behavior is the way Rainbow merges back the file. If you look at the OmegaT log you should see that when merging there are errors about trans-units being out of sync.

    The way the merge is done is to re-extract the original file with the same settings, and go through the translated entries at the same time. The issue is that if you add translate='no' to one entry in the XLIFF, the XLIFF filter used during the merge extracts only 2 TUs (the ones that are translatable), while the Text Filter extracts 3 TUs from the .txt file. Thus they get out-of-sync.

    Currently the only way to get the merge to work would be to remove the added translate='no' before the merge. You may be able to do this by running a Perl or Awk script in the command-line that merges back the XLIFF file, by removing all translate='no' in the target XLIFF before invoking the merger command from Rainbow. Maybe one of the script experts in the OmegaT user group can come up with such solution.

  2. x x reporter

    Thanks for answering. The AutoIt script bellow solves my problem. The post-processing command in OmegaT is now : path_to_autoit_script.exe

    #include <File.au3>
    $aXlfList = _FileListToArrayRec('path_to_omegat_project\target', '*.xlf', $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
    If @error Then Exit 1
    For $i = 1 To $aXlfList[0]
        $hFile = FileOpen($aXlfList[$i], $FO_UTF8_NOBOM)
        If $hFile = -1 Then Exit 1
        $sXlif = FileRead($hFile)
        If @error Then Exit 1
        $sXlif = StringReplace($sXlif, '<trans-unit translate="no"', '<trans-unit', 0, $STR_CASESENSE)
        If @extended Then
            $hFile = FileOpen($aXlfList[$i], BitOR($FO_OVERWRITE, $FO_UTF8_NOBOM))
            If $hFile = -1 Then Exit 1
            FileWrite($hFile, $sXlif)
    $sCmd = 'java -jar "path_to_okapi\lib\rainbow.jar" -x TranslationKitPostProcessing -np "path_to_omegat_project\manifest.rkm" -fc okf_rainbowkit-noprompt path_to_omegat_project\target\'
    $iCode = RunWait($sCmd, @WorkingDir, @SW_HIDE)
    Exit $iCode
  3. Log in to comment