API Pre-Translate Task not working for DeepL MT Provider

I have a FileBasedProject with :

  • Language pair: "de-DE" to "en-GB".
  • One file "fruits.xml".
  • One DeepL MT Translation Provider.

Screenshot of Studio Developers Q&A project settings showing a selected DeepL Translator provider for the language pair German to English.

Attempting to run the following code via the API completes without errors but does not pre-translate the file (no translations in the target segment):

    FileBasedProject ThisSdlProject = new FileBasedProject(SdlProjectFilePath);
    
    var settings = ThisSdlProject.GetSettings();
    var preTranslateSettings = settings.GetSettingsGroup();
    preTranslateSettings.NoTranslationMemoryMatchFoundAction.Value = NoTranslationMemoryMatchFoundAction.ApplyAutomatedTranslation;
    preTranslateSettings.TranslationOverwriteMode.Value = TranslationUpdateMode.KeepExistingTranslation;
    preTranslateSettings.MinimumMatchScore.Value = 75;
    ThisSdlProject.UpdateSettings(settings);
    
    ProjectFile[] translatableFiles = ThisSdlProject.GetTargetLanguageFiles(new Core.Globalization.Language(CultureInfo.GetCultureInfo(TargetLocale)));
    
    AutomaticTask preTranslateTask = ThisSdlProject.RunAutomaticTask(
        translatableFiles.GetIds(),
	    AutomaticTaskTemplateIds.PreTranslateFiles
    );
    
    ThisSdlProject.Save();

Screenshot of pre-translate settings with a minimum match value of 75 and options set to keep existing translation and apply automated translation when no match is found.

However, if I select the file in Studio 2021, Batch Tasks -> Pre-translate -> Finish (without changing any settings), it works:

Screenshot of 'fruits.xml' file in Studio Developers Q&A with source language German and target language English, showing untranslated words with NMT tag.

I swapped the DeepL MT Translation Provider for a File Based Translation Provider (Test_de-DE_en-GB.sdltm) and tried it again, and it worked as expected:

Screenshot of 'fruits.xml' file in Studio Developers Q&A with source language German and target language English, showing translated words with CM tag indicating confirmed matches.

Are there additional settings that must be applied in order for MT Translation Provider pre-translation to be applied via the API?

Thanks in advance,

Samuel



Generated Image Alt-Text
[edited by: RWS Community AI at 6:37 AM (GMT 0) on 15 Nov 2024]
  • Hello ,

    You should receive notification- however we have just released an updated version that should now work for you.

    Lydia Simplicio | RWS Group

    _______
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Hi Tomasz,

    I didn't use any log file, this is how I've troubleshot:

    1. For the first part of the investigation, I've used Fiddler to see if I received something from DeepL Service when the plugin tries to access the service. There I saw that the response is 403 and in the header the API key parameter is empty. (Even if I set the API key in the Studio project used for pre-translate).
    2. That being said I've tried to set programmatically the credentials on the project because I thought that the credentials are not taken from the Credential Store when we are using a stand-alone app. Even after I programmatically added the credentials to the project I still received 403 and the key wasn't retrieved.
    3. Credentials are retrieved based on the provider URI, the only difference which I saw was: when we created an empty project and adding the provider programmatically the provider URI used was "deepltranslationprovider:///". When the provider was added via Studio interface I saw in the plugin that is the URI received also contains the options selected (because we used the provider URI to save the options selected and then populate the UI accordingly).

    I hope this will help you. If you have more questions don't hesitate to ask.

    Have a nice day,

    Andrea