Hello,
I want to replicate the steps displayed in Studio during the upgrade/uplift process programmatically, but the API documentation is not very helpful on this.
After a little bit of trial and error with the actual methods offered in the Sdl.LanguagePlatform.TranslationMemoryApi dll for Studio 2019, I have come up with the following rough code. It seems to do the job for file-based TMs but I want to be sure there are no undesired side-effects.
Could somebody at SDL please confirm if these steps correspond to what the Upgrade Translation Memory command in the Studio application does?
private static void UpliftTM(FileBasedTranslationMemory tm)
{
if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresUpgrade(tm))
{
TranslationMemoryUpgradeUtil.UpgradeTranslationMemory(tm);
var token = new System.Threading.CancellationTokenSource().Token;
var progress = new Progress<int>(i => { });
if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresReindex(tm))
{
tm.SelectiveReindexTranslationUnits(token, progress);
}
if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresModelRebuild(tm))
{
tm.BuildModel();
}
if (TranslationMemoryUpgradeUtil.TranslationMemoryRequiresAlignment(tm))
{
tm.AlignTranslationUnits(true, false, token, progress);
}
}
if (tm.ShouldRecomputeFuzzyIndexStatistics())
{
tm.ClearFuzzyCache();
tm.RecomputeFuzzyIndexStatistics();
}
tm.Save();
}
Thanks,
Attila