Exporting/Importing Bilingual Review documents. Import not working.

Hi

I am writing a program to export and import Bilingual Review documents for all files in a project using Trados Studio 2021 SR1 (build 16.1.5.4270).

The export part of the program is working fine. The folder used for the export is picked up from the project settings Language Pairs\All Language Pairs\Batch Processing\Export for Bilingual Review 

However, the import part of the program does nothing. Here's my code.

            Console.WriteLine("ImportBilingualReviewDocs");
            Console.WriteLine("START Import");
            AutomaticTask exportReview = project.RunAutomaticTask(
                targetFiles.GetIds(),
                AutomaticTaskTemplateIds.UpdateFromExternalReview,
                (sender, taskStatusArgs) => taskStatusEventArgsList.Add(taskStatusArgs),
                (sender, messageArgs) => messageEventArgsList.Add(messageArgs));
            Console.WriteLine("END ImportBilingualReviewDocs");

The output is:

ImportBilingualReviewDocs
START Import
END ImportBilingualReviewDocs

Checking the project proves it has not imported my changes.

I think it's failing to do anything because it does not know where the review DOCX files are located. I cannot see a way to specify this (I was expecting the program to use the project setting value above).

Can anyone enlighten me as to what I'm doing wrong? Can you share any working code examples?

Best Regards

Mark

emoji
Parents
  • Hi  ,

    You will need to set the ImportFromReviewTaskSettings settings to provide the automation task the context to locate the updated documents.

    Note: You will need to update that settings group, before running the automation task.  If you need support in understanding how to update a settings group on the project, then make reference to here; the concept is the same.

    UI Reference:

    Trados Studio Batch Processing window showing Bilingual Review Document Update with a German project file selected and options to change status of updated segments or create a backup.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 1:38 PM (GMT 0) on 5 Mar 2024]
  • Hi Patrick,

    My method is to iterate the target files in the project and map/import for each file.

    I am struggling with how to use the "mappings" list that I set on line 14. The ExternalReviewMappingItems property is read only so I cannot set it to my mappings. 

            public void ImportBilingualReviewDocs()
            {
    
                ISettingsBundle settings = project.GetSettings(trgLang);
    
                ImportFromReviewTaskSettings impSettings = settings.GetSettingsGroup<ImportFromReviewTaskSettings>();
    
                List<ExternalReviewMappingItem> mappings = new List<ExternalReviewMappingItem>();
    
                ProjectFile[] files = project.GetTargetLanguageFiles();
                for (int i = 0; i < files.Length; i++)
                {
                    string XliffFilePath = files[i].LocalFilePath;
                    string BilingualReviewFileFullPath = XliffFilePath.Replace("sdlxliff", "review.docx").Replace(projectFolder, projectFolder + @"\External Review");
                    Console.WriteLine("SDLXLiff {0}\nDOCX {1}", XliffFilePath, BilingualReviewFileFullPath);
                    mappings.Add(new ExternalReviewMappingItem(XliffFilePath, project.GetProjectInfo().Id, BilingualReviewFileFullPath));
                    
                    impSettings.Backup.Value = false;
                    impSettings.ConfirmationLevel.Value = ConfirmationLevel.Translated;
                    project.UpdateSettings(trgLang, settings);
                    Guid[] fileId = { files[i].Id };
    
                    AutomaticTask task = project.RunAutomaticTask(
                        fileId,
                        AutomaticTaskTemplateIds.UpdateFromExternalReview);
                    
                    CheckEvents(taskStatusEventArgsList, messageEventArgsList);
                    if (task.Status.ToString() != "Completed")
                    {
                        Console.WriteLine("\tImporting Reviewed DOCX - status = " + task.Status.ToString());
                        ExecutionMessage[] errors = task.Messages;
                        foreach (ExecutionMessage error in errors)
                            Console.WriteLine(error.Message);
                    }
                    else
                        Console.WriteLine("Imported DOCX file successfully.");
    
                }
            }
    
     

    Any help gratefully received...

    Regards
    Mark

    emoji
Reply
  • Hi Patrick,

    My method is to iterate the target files in the project and map/import for each file.

    I am struggling with how to use the "mappings" list that I set on line 14. The ExternalReviewMappingItems property is read only so I cannot set it to my mappings. 

            public void ImportBilingualReviewDocs()
            {
    
                ISettingsBundle settings = project.GetSettings(trgLang);
    
                ImportFromReviewTaskSettings impSettings = settings.GetSettingsGroup<ImportFromReviewTaskSettings>();
    
                List<ExternalReviewMappingItem> mappings = new List<ExternalReviewMappingItem>();
    
                ProjectFile[] files = project.GetTargetLanguageFiles();
                for (int i = 0; i < files.Length; i++)
                {
                    string XliffFilePath = files[i].LocalFilePath;
                    string BilingualReviewFileFullPath = XliffFilePath.Replace("sdlxliff", "review.docx").Replace(projectFolder, projectFolder + @"\External Review");
                    Console.WriteLine("SDLXLiff {0}\nDOCX {1}", XliffFilePath, BilingualReviewFileFullPath);
                    mappings.Add(new ExternalReviewMappingItem(XliffFilePath, project.GetProjectInfo().Id, BilingualReviewFileFullPath));
                    
                    impSettings.Backup.Value = false;
                    impSettings.ConfirmationLevel.Value = ConfirmationLevel.Translated;
                    project.UpdateSettings(trgLang, settings);
                    Guid[] fileId = { files[i].Id };
    
                    AutomaticTask task = project.RunAutomaticTask(
                        fileId,
                        AutomaticTaskTemplateIds.UpdateFromExternalReview);
                    
                    CheckEvents(taskStatusEventArgsList, messageEventArgsList);
                    if (task.Status.ToString() != "Completed")
                    {
                        Console.WriteLine("\tImporting Reviewed DOCX - status = " + task.Status.ToString());
                        ExecutionMessage[] errors = task.Messages;
                        foreach (ExecutionMessage error in errors)
                            Console.WriteLine(error.Message);
                    }
                    else
                        Console.WriteLine("Imported DOCX file successfully.");
    
                }
            }
    
     

    Any help gratefully received...

    Regards
    Mark

    emoji
Children
No Data