Calling TM Providers via the API

Hi,

We have two questions related to the use of TM Providers in Trados Studio:

  1. Is it possible to download via API only information about plugins that are of the "TMs engine plugin" type that can be used in the translation resource (as in the screenshot)? We would like to download a list of tms engine plugins installed in trados. Is there any special method for this? If not, then how can we determine if a given plugin is of the "TMs engine" type? The method IPluginRegistry DefaultPluginRegistry returns all installed plugins, unfortunately it does not specify the type, e.g. TMS engine
    Trados Studio screenshot showing the Translation Resources tab with a dropdown menu for TM Providers, listing various TM engine plugins available.

  2. How should we use the API, that the project uses a given TM engine? Should we use fileBasedProject.UpdateTranslationProviderConfiguration?


Generated Image Alt-Text
[edited by: Trados AI at 4:07 AM (GMT 0) on 5 Mar 2024]
Parents
  • Hi ,

    Is it possible to download via API only information about plugins that are of the "TMs engine plugin" type that can be used in the translation resource (as in the screenshot)? We would like to download a list of tms engine plugins installed in trados. Is there any special method for this? If not, then how can we determine if a given plugin is of the "TMs engine" type? The method IPluginRegistry DefaultPluginRegistry returns all installed plugins, unfortunately it does not specify the type, e.g. TMS engine

    It is possible to get a list of extensions from the plugin manager by attribute type (e.g. TranslationProviderFactoryAttribute) and validate whether it supports a uri scheme and/or host:

    Example:

    var extensionPoint = PluginManager.DefaultPluginRegistry.GetExtensionPoint<TranslationProviderFactoryAttribute>();
    if (extensionPoint == null)
    {
    	return;
    }
    foreach (var extension in extensionPoint.Extensions)
    {
    	// 1. identify if the provider is enabled
    	if (!extension.Enabled)
    	{
    		continue;
    	}
    
    	// 2. identify if the extension is a provider of interest to you
    	// from here you can identify the type
    	// extension.ExtensionType == etc..
    	// extension.Plugin.Id == etc...
    
    	// 3. create an instance of the providers factory
    	var factory = (ITranslationProviderFactory)extension.CreateInstance();
    	if (factory == null)
    	{
    		continue;
    	}
    
    	// 4. check if a specific uri is supported by the provider
    	var supported = factory.SupportsTranslationProviderUri(new Uri("scheme://my.domain.com"));
    }    


    How should we use the API, that the project uses a given TM engine? Should we use fileBasedProject.UpdateTranslationProviderConfiguration?

    Yes, correct, please make reference to the example from 

  • Hi
    Thank you for your explanation,
    Could you please also advise what in case when specific TM plugin is not yet added to any project?
    Can we get it's URI in this case?
    Kind Regards,
    Tomasz

  • You can recover the uri of the providers from the project instances or project files (xml), but not possible to identify the uri before hand, as it is assigned when the provider is created (via the factory as explained earlier); + how developers code the provoder is entirely at their own discretion as long as they fully implement the ITranslationProvider interface.

    You could attempt to load the providers via reflection, but I wouldn't advise it as best practice assumes that data is injected via the constructor, which brings you right back to the initial problem!

    If you need to obtain a list of the URI for all providers, why not simply create a project (or template) with all providers, and then either parse that data from the project xml or via the API if its loaded in the project container.  Make sense?

Reply
  • You can recover the uri of the providers from the project instances or project files (xml), but not possible to identify the uri before hand, as it is assigned when the provider is created (via the factory as explained earlier); + how developers code the provoder is entirely at their own discretion as long as they fully implement the ITranslationProvider interface.

    You could attempt to load the providers via reflection, but I wouldn't advise it as best practice assumes that data is injected via the constructor, which brings you right back to the initial problem!

    If you need to obtain a list of the URI for all providers, why not simply create a project (or template) with all providers, and then either parse that data from the project xml or via the API if its loaded in the project container.  Make sense?

Children