Creating Project Package for Studio 2009 from Studio 2011 with C#

I’m developing an application in C# which is intended to make some “manual” task automatic. I’m working with 2011 API version and I need to create translator package for 2009 studio version as menu item “Create Studio 2009 Project Package”  does.

I’m able to create package version for 2011, but searching through Sdl.ProjectAutomation 2011 api I couldn’t find anything helpful for creating the package for the earlier version. I’ve searched through  ProjectPackageCreationOptions Class or ProjectPackageCreation Class and others  under all Sdl.ProjectAutomation.Core.

Am I looking in the right place? Is there any place where  to set the final version for the package?

Thanks.

giorgio

Parents Reply Children
  • From the answer I got on another occasion this is not gonna change anymore. You have to upgrade to 2012.

  • i have decided to go back to this thread and paste my solution. Packages in 2011 and 2009 are very similar.

    Solution below will unpack trados 2011 package, changes some values that trados 2009 will be able to read this package and zip files back.

    Package will not have QA or Term verification settings converted, but this can be done in a vey easy way as well.

    Code:

          public static void Trados2011PackageConvert(string packagefile)

           {

               string f_type_folder = @"C:\Project 1\pkg\File Types";

               string target_zip = packagefile.Replace(Path.GetFileName(packagefile), "Trados2009_"+Path.GetFileName(packagefile));

            

               string folder = packagefile.Replace(Path.GetFileName(packagefile),

                   Path.GetFileNameWithoutExtension(packagefile));

               if (Directory.Exists(folder)) Directory.Delete(folder);

               Directory.CreateDirectory(folder);

            

               Process prc_unzip = new Process();

               prc_unzip.StartInfo.FileName = @"C:\Program Files (x86)\SDL\SDL Trados Studio\Zipper\Trados2011_Zipper.exe";

               prc_unzip.StartInfo.Arguments = String.Format("unzip \"{0}\" \"{1}\"", packagefile, folder);

               prc_unzip.Start();

               prc_unzip.WaitForExit();

               string[] files = Directory.GetFiles(folder, "*.sdlproj", SearchOption.TopDirectoryOnly);

               Trace.WriteLine(files.Count());

               Trace.WriteLine(files[0]);

               XmlDocument doc = new XmlDocument();

               doc.Load(files[0]);

               doc.XmlResolver = null;

               XmlNode node = doc.SelectSingleNode("//PackageProject");

               node.Attributes["Version"].Value = "3.1.0.0";

               doc.Save(files[0]);

               string file_type_folder = Path.Combine(folder, "File Types");

               Directory.CreateDirectory(file_type_folder);

               string[] f_to_copy = Directory.GetFiles(f_type_folder);

               foreach (string f in f_to_copy)

               {

                   string f_target = Path.Combine(file_type_folder, Path.GetFileName(f));

                   File.Copy(f, f_target);

               }

               string err = "";

           

           Process prc_zip = new Process();

           prc_zip.StartInfo.FileName = @"C:\Program Files (x86)\SDL\SDL Trados Studio\Zipper\Trados2011_Zipper.exe";

               prc_zip.StartInfo.Arguments = String.Format("zip \"{0}\" \"{1}\"", folder, target_zip);

               prc_zip.Start();

               prc_zip.WaitForExit();

               Directory.Delete(folder,true);

           }

    i had to use Trados2011_Zipper.exe as my application works inside Trados Studio folder and has sharpziplib version conflict with sharpziplib library used by sdl.

    Most important part is bolded.

    Note : this will work correctly only if you dont use options specific to trados 2011.