Sample code to save SDLXLIFF to target document

Hi everyone. Could someone please share with me on any sample code to save a SDLXLIFF into a target document?

I could do it in Trados Studio 2015, by opening a SDLXLIFF file (double-clicking on the file) , then File->Save Target As.

How may I do this in C#?

I was following the codes in producthelp.sdl.com/.../aa730e1e-2ab1-4d05-b57b-a2daccf64694.htm but how may I run the project to save to the target files?

I tried all the batch task types, but all did not generated the target document from the xliff.

Please help.

Thanks a million!

Parents Reply
  • Hi Hoon Kim (HoonKim) ,

    You are referring to the "SaveProjectFileAs" method right? I saw in my notifications that you suggested that, even if I cannot see that response appear in this thread now.

    That method - as the name suggests - saves the _project_ file, not the resulting target file. So by saving it as .docx, you are actually not saving as .docx but just renaming the sdlxliff to docx, which _ruins_ the file.

    As for specifying another path: you can't. What you _can do though is using the target file's language ISO code to determine the folder in your studio project and then use "File.Copy" method to copy the resulting target file to your desired location.

    Example:

    var studioFolder = Path.GetDirectoryName(project.FilePath);
    var filName = Path.GetFileName(tFile.LocalFilePath);
    if (Path.GetExtension(filName) == ".sdlxliff")
        filName = Path.GetFileNameWithoutExtension(tFile.LocalFilePath);

    var pathFrom = Path.Combine(studioFolder, tFile.Language.IsoAbbreviation, filName);
    var pathTo = Path.Combine(destinationFolder, filName);
    File.Copy(pathFrom, pathTo, true);

     

    : I'll take a look at that import problem later and see what I find.

    Best,

    Andreas

Children