API Program to create multiple projects - pre-translate failures

Hi,

I have created a program calling the Trados API that generates multiple Trados projects from the same template project.

The program creates the project, adds files recursively from a folder, scans the files, creates the translatable format, copies the translatable format files to the target language, pre-translates the files, analyses the files.

There are 82 Trados projects created in this way, one after the other, via a Jenkins job running an Ant script that calls my program 82 times. Across all 82 projects there are over 14K files.

Due to the number of files involved, I cleanup the AppData\Local\Temp folder for my user prior to each project creation.

I have noticed that a full run results in a number of projects failing to Pre-Translate properly. The status returned is "Failed".

QUESTION: I do not know how to dig out the precise reason for the failure so can anyone push me in the right direction?

The next time I run my script, concentrating only on those projects that did not pre-translate. Some that failed now pre-translate. No changes to the program, I simply re-ran it.

Subsequent runs reduce down the list of failed projects to zero after another 4 or 5 iterations.

This is obviously strange.

QUESTION: Can anyone suggest why I get this behavior as I'd like to be able to do a single job run to create them all? 

Best Regards

Mark

Parents Reply
  • Hi Samuel,

    Sure here's what I'm using to do the Pre-Translate You could use a similar approach for the Analysis side too I reckon:

            public bool PreTranslateIndividualTargetLanguageFiles(FileBasedProject project, string locale)
            {
                #region "Pretranslate"
                Console.WriteLine("Pre-translate start");
                List<TaskStatusEventArgs> taskStatusEventArgsList = new List<TaskStatusEventArgs>();
                List<MessageEventArgs> messageEventArgsList = new List<MessageEventArgs>();
    
                Language targetLanguage = new Language(CultureInfo.GetCultureInfo(locale));
    
                ProjectFile[] targetFiles = project.GetTargetLanguageFiles(targetLanguage);
                Console.WriteLine("Pre-translating " + targetFiles.Count() + " files");
                for (int i = 0; i < targetFiles.Length; i++)
                {
                    if (targetFiles[i].Role == FileRole.Translatable)
                    {
                        Guid[] fileId = { targetFiles[i].Id };
                        AutomaticTask translateTask = project.RunAutomaticTask(
                            fileId,
                            AutomaticTaskTemplateIds.PreTranslateFiles);
                        CheckEvents(taskStatusEventArgsList, messageEventArgsList);
                        if (translateTask.Status.ToString() != "Completed")
                        {
                            Console.WriteLine("\t" + fileId.ToString() +  "\tPre-translate " + translateTask.Status.ToString());
                            ExecutionMessage[] errors = translateTask.Messages;
                            foreach (ExecutionMessage error in errors)
                            {
                                Console.WriteLine(error.Message);
                            }
                            return false;
                        }
                        //else
                        //    Console.WriteLine("Pre-translate " + translateTask.Status.ToString());
                    }
                }
    
                return true;
                #endregion
            }

    I hope that formats properly!
    Cheers

    Mark

Children