public void GetTmsForTemplate(TranslationProviderServer tmServer, string templateName) { #region "SelectTemplate" ServerBasedLanguageResourcesTemplate template = tmServer.GetLanguageResourcesTemplate(templateName, LanguageResourcesTemplateProperties.All); #endregion #region "LoopTms" string tmList = string.Empty; foreach (ServerBasedTranslationMemory tm in template.TranslationMemories) { tmList += tm.Name + "\n"; } MessageBox.Show(tmList); #endregion }
public void Create(TranslationProviderServer tmServer, string organizationPath, string containerName, string tmName) { #region "CheckExists" foreach (ServerBasedTranslationMemory item in tmServer.GetTranslationMemories(TranslationMemoryProperties.None)) { if (item.Name == tmName) { throw new Exception("TM with that name already exists."); } } #endregion #region "TM" ServerBasedTranslationMemory newTM = new ServerBasedTranslationMemory(tmServer); newTM.Name = tmName; newTM.Description = "Programmatically created sample TM"; newTM.Copyright = "(c) 2010 SDL International"; #endregion string containerPath = organizationPath; if (!containerPath.EndsWith("/")) { containerPath += "/"; } #region "container" containerPath += containerName; TranslationMemoryContainer container = tmServer.GetContainer(containerPath, GetContainerProperties()); newTM.Container = container; #endregion #region "LanguageDirection" CreateLanguageDirections(newTM.LanguageDirections); #endregion #region "org" newTM.ParentResourceGroupPath = organizationPath; #endregion string templatePath = organizationPath; if (!templatePath.EndsWith("/")) { templatePath += "/"; } #region "templates" string sampleFieldTemplateName = "MyFieldTemplate"; foreach (ServerBasedFieldsTemplate template in tmServer.GetFieldsTemplates(FieldsTemplateProperties.All)) { if (template.Name == sampleFieldTemplateName) { newTM.FieldsTemplate = tmServer.GetFieldsTemplate( templatePath + sampleFieldTemplateName, FieldsTemplateProperties.Fields); break; } } string sampleLanguageResourcesTemplateName = "MyLanguageResourcesTemplate"; foreach (ServerBasedLanguageResourcesTemplate template in tmServer.GetLanguageResourcesTemplates( LanguageResourcesTemplateProperties.LanguageResources)) { if (template.Name == sampleLanguageResourcesTemplateName) { newTM.LanguageResourcesTemplate = tmServer.GetLanguageResourcesTemplate( templatePath + sampleLanguageResourcesTemplateName, LanguageResourcesTemplateProperties.None); break; } } #endregion newTM.Save(); }