Create WorldServer return package from Trados Studio 2015

I would like to create a plugin that allows the user to create a return kit in SDL Trados Studio 2015 and upload to the server from the Editor View.

What is the best method to access this functionality from the API?

I tried of course the FileBasedProject.CreateReturnPackage Method

But, this creates a Studio Return Package. This method produces a return package that cannot be imported to WorldServer, it produces this error message: "The import attempt failed because the selected file "Testpackage-2016516-10h59m0s.sdlrpx" does not have a recognizable extension by WorldServer, or metadata file is missing from the contents of the selected file if the file is a zip archive."

What is needed is an *.wsxz package created from this *.sdlrpx. The wsxz is essentially a stripped down xliff in a zip file that can be imported by the WorldServer.

Thanks in advance.

Parents
  • Hello Balázs,
    Just rename your package with "zip" as extension instead of sdlrpx. This should work.
    Do you already know how to upload the files on worldserver? With the worldserver REST API or with the studio API? I have a similar project myself.
    Kind regards
    Sébastien
  • Hi Sébastian. I tried, but unfortunately the package that is created has the incorrect content. WorldServer expects a zip-ed xlf. The Trados package unless converted to wsxz has a Trados project file, the original xlf and and sdlxliff off the current state of the Trados project. No bueno. No, I have not gotten into the upload part (but my collegue does have that part covered, we have plugin that uses the WS services already). Before I dive into it, I want to first sort out if it is possible at all to create an upload package. I have a workaround in place already where I actually automate the upload from within Studio by the default hotkeys, but of course this is very lame. Only until now I was not able to find an exposed API for the WS return kit.
    Best, Balázs
  • Hello Balázs,
    I've read your last answers on other threads and I think I understand how you work: you download xlf files from WorldServer and prepare them in Studio with the wsxliff or the xliff filetype. Is this right? In this case, you have to convert the sdlxliff back to xlf first. I haven't try it, but it seems that the "savetargetas" method of the editorcontroller does the job. Then, try to upload the file on worldserver directly with the plugin you mentioned. I'm not sure you have to zip the xlf files before.

    The other way to translate worldserver files is to download wsxz packages which contain sdlxliff files. In this case, you will be able to work with project TMs and termbases if available and you don't have to "savetargetas": you just have to zip the sdlxliff as they are and upload them on worldserver.

    Kind regards
    Sébastien
  • Hi Sébastien,

    This is a great hint, thanks.

    The problem with this approach is that all this method do is displaying the Save Target As dialog expecting the user to reply, I did not find a way to automate the process so that my code can pickup the xlf and upload it with the credentials already acquired from the user.

    In fact the code is halted at the line of the method and does not progress on.

    So I had to make a workaround to automate the window itself from a separate thread:

            private void DoSaveAs()
            {
                while (NativeMethods.GetActiveWindowTitle() != "Save Target As")
                {
                    Thread.Sleep(500);
                }
                SendKeys.SendWait(@"d:\test.xlf");
                SendKeys.SendWait("{ENTER}");
            }
    
            private void ShowSaveAsDialog()
            {
                EditorController.SaveTargetAs(EditorController.ActiveDocument);
            }
    
            private void DoUpload()
            {
                Task task = new Task(DoSaveAs);
                
                task.Start();
                ShowSaveAsDialog();
    
                while (!task.IsCompleted)
                {
                    Thread.Sleep(500);
                }
            }

     The only problem is that this only works for the xlf files.

    The sdlxliff wants to save as the target file in their native format. (I could use the Save Copy As function to save the sdlxliff but that cannot be imported by the WS.)

    So really I am at the same place where I was. The best method is still the automation I have in place.

    I have not given up looking though.

    Best, Balázs

  • Hello Balázs,
    Thanks for remembering me what savetargetas does. I used it once in the past and I think I programmed it as you described.

    Regarding sdlxliff files, if the savetargetas function gives you a file in the native format, I assume that the sdlxliff has been created in worldserver: so just upload the sdlxliff. You don't have to create the target. If uploading the sdlxliff file does not work, zip it first and then it should work.

    Kind regards
    Sébastien
  • Thanks for the reply and keeping up with me. This ZIP-ing the SDLXLIFF was a very good tip.

    The point is that while current projects are using FTS there are a great numbers of in progress legacy projects.

    So the upload need to be able to handle both.

    So I could theoretically test the file format and based on that create the current XLIFF in the right format, like so:

            private void DoSaveAs()
            {
                while (NativeMethods.GetActiveWindowTitle() != "Save Target As")
                {
                    Thread.Sleep(500);
                }
                SendKeys.SendWait(@"d:\test.xlf");
                SendKeys.SendWait("{ENTER}");
            }
    
            private void DoSaveAsFTSfile()
            {
                while (NativeMethods.GetActiveWindowTitle() != "Save As")
                {
                    Thread.Sleep(500);
                }
                SendKeys.SendWait(@"d:\test.sdlxliff");
                SendKeys.SendWait("{ENTER}");
            }
    
            private void DoUploadNew()
            {
                foreach (var item in EditorController.GetDocuments())
                {
                    EditorController.Save(item);
                }
    
                if (EditorController.ActiveDocument.ActiveFile.FileTypeId != null && 
                    EditorController.ActiveDocument.ActiveFile.FileTypeId.ToString().StartsWith("WsXliff"))
    { Task task = new Task(DoSaveAs); task.Start(); EditorController.SaveTargetAs(EditorController.ActiveDocument); while (!task.IsCompleted) { Thread.Sleep(500); } } else { Task task = new Task(DoSaveAsFTSfile); task.Start(); EditorController.SaveTargetAs(EditorController.ActiveDocument); while (!task.IsCompleted) { Thread.Sleep(500); } EditorController.SaveAs(EditorController.ActiveDocument); } }

    Then the only trick left is to actually do a simple upload.

    So as not to reinvent the wheel here, may I ask if you can lend me the code snippet for uploading the files in the foreground?

    Thanks,

    Balázs

  • Hi Balázs,
    You mean the code to upload the files in worldserver?
    This is a part I also need. But I have no access to a worldserver instance to write it myself. If you get some clues, maybe you can share them here.

    Kind regards
    Sébastien
  • Dear Sébastien,

    Could you share your code on how to upload a file on SDL WorldServer via the REST API? I haven't found it in the documentation.

    Thanks for your support.

    Regards,

    Laurent
  • Hi Laurent,
    I've just read your request: I'm sorry, but I have no code at all for the REST API. We upload the files manually.
    Kind regards
    Sébastien
Reply Children