Change file phase from Studio plugin through desktop API

Hi,

is there any way to change the phase of a translation file to Review from the plugin? I see that on the REST API there is an action for this, but in the desktop Studio API I have not found a similar feature. Is there any possibility to do this still? (Or can I use the REST API without having to re-enter the credentials in Studio?)

Thanks,

Tamas

Parents
  • Hi  Tamás,

    Unfortunately it doesn't exist.
    If you have a FileBasedProject, you might be able to use reflection as a workaround (not fully tested yet):

               var project = filebasedProject.GetType().GetField("_project", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(filebasedProject);

               var changePhase = project.GetType().GetMethod("ChangeCurrentPhase", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

               var getProjectFiles = project.GetType().GetMethod("GetProjectFiles", new Type[] { typeof(Sdl.Core.Globalization.Language) });

               changePhase.Invoke(project, new object[] { "Review", getProjectFiles.Invoke(project, new object[] { language }), "comment" });

    I guess the string you pass can be "Preparation", "Translation", "Review" and "Finalization", but I wasn't able to test that part right now.

Reply
  • Hi  Tamás,

    Unfortunately it doesn't exist.
    If you have a FileBasedProject, you might be able to use reflection as a workaround (not fully tested yet):

               var project = filebasedProject.GetType().GetField("_project", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(filebasedProject);

               var changePhase = project.GetType().GetMethod("ChangeCurrentPhase", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);

               var getProjectFiles = project.GetType().GetMethod("GetProjectFiles", new Type[] { typeof(Sdl.Core.Globalization.Language) });

               changePhase.Invoke(project, new object[] { "Review", getProjectFiles.Invoke(project, new object[] { language }), "comment" });

    I guess the string you pass can be "Preparation", "Translation", "Review" and "Finalization", but I wasn't able to test that part right now.

Children