Programmatically Pre-translate a Project with Language Weaver as a MT resource

Hi,

Got a strange one here.

I have a C# program that creates a project via a template, adds source files and pre-translates using the relevant Language pair resources specified in the project template.

The code works perfectly with any project templates that have:

  • A translation memory
  • And/or have a DeepL plugin

I have created a new template that uses Cloud-based resources (Language Weaver with the correct language pair, using Generic - NMT).

I run same program (no code changes) and it creates the project, adds the source files and runs through the code to do the pre-translate.

But, when I manually open the created project it has not done the pre-translate.

I can manually do a pre-translate and it does use LW to perform MT. 

Is there anything wrong with the code below that's stopping the PT?

Here's the method that does the PT:

internal void PreTranslateFilesMT(int minimumrate)
{

if (newProject != null)
{
    Console.WriteLine("START MT PreTranslateFiles with memory enabled");

    Console.WriteLine("Setting project minimum pre-translate match to {0}", minimumrate);
    var settings = newProject.GetSettings();
    var preTranslateSettings = settings.GetSettingsGroup<TranslateTaskSettings>();
    preTranslateSettings.NoTranslationMemoryMatchFoundAction.Value = NoTranslationMemoryMatchFoundAction.ApplyAutomatedTranslation;
    preTranslateSettings.MinimumMatchScore.Value = minimumrate;
    newProject.UpdateSettings(settings);
    newProject.Save();
    var targetFiles = newProject.GetTargetLanguageFiles();

    newProject.RunAutomaticTasks(targetFiles.GetIds(), new[]
    {
        AutomaticTaskTemplateIds.PreTranslateFiles,
    });
    newProject.Save();
    Console.WriteLine("END MT PreTranslateFiles with memory enabled");
}
else
    Console.WriteLine("NULL new project!");

}

Thanks

Mark