SDL SDK Api PreTranslateFiles randomly fails

I am stumped.

I have a very basic SDK app, that requires an SDL Project file path and a target language; then attempts to run the "PreTranslateFiles" task.

namespace Sdl.Sdk.PreTranslateFiles
{
    using System;
    using System.Globalization;
    using Sdl.Core.Globalization;
    using Sdl.ProjectAutomation.Core;
    using Sdl.ProjectAutomation.FileBased;
    public class PreTranslateFiles
    {
        public void Create(
            string SdlProjectFilepath,
            string SdlTargetLanguage
        )
        {
            FileBasedProject ThisSdlProjectObject = new FileBasedProject(SdlProjectFilepath);
            this.RunAutomaticTask(ThisSdlProjectObject, SdlTargetLanguage);
            ThisSdlProjectObject.Save(); 
        }
        private void RunAutomaticTask(FileBasedProject ThisSdlProject, string TargetLanguageCode)
        {
            ProjectFile[] targetFiles = ThisSdlProject.GetTargetLanguageFiles(new Language(CultureInfo.GetCultureInfo(TargetLanguageCode)));
            AutomaticTask preTranslate = ThisSdlProject.RunAutomaticTask(targetFiles.GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles);            
        }
    }
}

However, for reasons that I cannot figure out, the "PreTranslateFiles" task randomly fails to run, which results in the error message "Index was outside the bounds of the array"; if/when attempting to run the "AnalyzeFiles".

My tests (run in batches of 20 reps) are based on an SDL Project; which have files already converted to translatable format and are copied to target languages.

  • Test 1, set up using a template: resulted in 15% failure rate
  • Test 2, same as Test 1: resulted in 25% failure rate
  • Test 3, same as Test 1&2: resulted in 45% failure rate
  • Test 4, reset SDL program and user settings to default, set up using a template: resulted in 55% failure rate
  • Test 5, set up without using a template: resulted in 20% failure rate

I have also monitored the %USERPROFILE%\AppData\Local\Temp directory, and noticed that the SDL randomly-generated .zip, .tmp files and directories are not created when the task fails.

I added a couple of real-time protection exclusion rules to:

  •  %USERPROFILE%\AppData\Local\Temp
  • C:\Program Files (x86)\SDL\*

...but this did not change anything.

Has anyone had any experience like this, or have any clue why the "PreTranslateFiles" task would decide to randomly fail?

Thanks in advance

Parents Reply
  • Thanks, but this sample code is for setting up a new project, then adding a translation memory then running automatic tasks.

    We use project templates to set up our projects; then run automatic tasks.

    For my problem, I have tried to simplify/isolate the problem to a specific task, "PreTranslateFiles". 

    Whether the task is run within the same program where the project is created or run on the same project afterwards doesn't make a difference. 

    Using one Translation Memory instead of three makes no difference either.

    Logically, if the process is the same, as well as the project and the files; then so too should the result.

Children
No Data