Accessing a Projects Translation Memories from a Translation Provider Plug-In

Hi everybody,

I am developing a translation provider plug-in that utilizes machine translation for Trados Studio 2024 and I have used the translation provider plugin template to set up the project. My machine translation will be able to utilize fuzzy translations based on Translation Memories to improve the translation result.

For this I need to access the Translation Memories in the project. To make this work I added the necessary Assemblies to be able to use the automation framework. These are not configured automatically in that template.

Now I can query the existing Translation Memories in the project with:

ProjectsController projectsController = SdlTradosStudio.Application.GetController<ProjectsController>();
FileBasedProject currentProject = projectsController.CurrentProject;
TranslationProviderConfiguration config = currentProject.GetTranslationProviderConfiguration();

Then iterate over the config, get the provider reference, its Uri, check if it is a FileBasedTranslationMemory and then create a new FileBasedTranslationMemory to be able to search on it.

foreach (TranslationProviderCascadeEntry entry in config.Entries)
{
    TranslationProviderReference mtp = entry.MainTranslationProvider;
    List<TranslationProviderReference> ptms = entry.ProjectTranslationMemories;
    
    if (FileBasedTranslationMemory.IsFileBasedTranslationMemory(mtp.Uri)) 
    {
        string tmPath = FileBasedTranslationMemory.GetFileBasedTranslationMemoryFilePath(mtp.Uri);
        FileBasedTranslationMemory fbTm = new FileBasedTranslationMemory(tmPath);
        //...
    }
    
    //same for ptms I think

}

Now my questions:
Would it also be possible somehow to get the TranslationMemory objects, that Trados uses internally directly if they are active in the project anyway?

With the method described above: does the FileBasedTranslationMemory object get updated automatically if the corresponding Translation Memory gets updated, e.g. if a new translation gets added, or do I need to check it manually somehow and then create a new FileBasedTranslationMemory object?

Do you have any additional infos that I might need here? Am I on the right track with the Automation API?

Thank you in advance!
- Lukas

  • Hi  , you're on the right track in concept, but le'ts take a look at some important details in yr approach. 

    Access TranslationMemory Objects:
    The Automation API does not expose internal instances of Translation Memory objects used by Studio directly to plug-ins. As you already know, given yr example above, you can access references or paths (like URI, yr doing) to TMs via the TranslationProviderConfiguration but not the "live" TM objects with internal state. FileBasedTranslationMemory class you create with the TM file path is essentially a wrapper that opens the TM file on disk, but it is not the exact same object Studio uses internally during a project session.

    Updating FileBasedTranslationMemory Object:
    Understanding this, you shouldn't expect that the FileBasedTranslationMemory you instantiate yrself to automatically reflect updates such as new added segments while Studio is running. Most likely, to see updates, you would need to refresh or create a new instance of FileBasedTranslationMemory to see the latest data from disk.