I'm trying to programmatically add server-based TMs to a project, but am unable to.
Having read through this thread I have the following code
public void AddServerBasedTM(FileBasedProject project, Language targetLanguage, ServerBasedTranslationMemory serverTM)
{
var tmConfig = project.GetTranslationProviderConfiguration();
tmConfig.Entries.Add(new TranslationProviderCascadeEntry(new TranslationProviderReference(serverTM.Uri,
serverTM.SerializeState(),
true),
true,
true,
true,
0));
project.Credentials.AddCredential(serverTM.Uri, $"user=[...];password=[..];type=CustomUser");
project.UpdateTranslationProviderConfiguration(targetLanguage, tmConfig);
project.AddMasterTM(tmConfig, targetLanguage.IsoAbbreviation);
project.Save();
}
The above code results in the following being added to the .sdlproj file:
<LanguageDirections>
<LanguageDirection Guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" SettingsBundleGuid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TargetLanguageCode="en-GB" SourceLanguageCode="de-CH">
<AutoSuggestDictionaries />
<CascadeItem OverrideParent="false" StopSearchingWhenResultsFound="false">
<CascadeEntryItem PerformConcordanceSearch="true" Penalty="0" PerformUpdate="true" PerformNormalSearch="true">
<MainTranslationProviderItem Uri="sdltm.my.server.url/groupshare" Enabled="true" />
</CascadeEntryItem>
</CascadeItem>
</LanguageDirection>
</LanguageDirections>
However, upon opening the project no TMs appear to be referenced (either under "All Language Pairs" or under the specific pairing):