public void CreateTemplate(TranslationProviderServer tmServer) { #region "TemplateProps" ServerBasedLanguageResourcesTemplate template = new ServerBasedLanguageResourcesTemplate(tmServer); template.Name = "Sample Language Resources Template"; template.Description = "Language Resources template created through API"; #endregion #region "variables" LanguageResourceBundle variables = new LanguageResourceBundle(CultureInfo.GetCultureInfo("en-US")); variables.Variables.Add("SDL Trados Studio 2009"); variables.Variables.Add("SDL MultiTerm 2009"); #endregion #region "abbreviations" LanguageResourceBundle abbreviations = new LanguageResourceBundle(CultureInfo.GetCultureInfo("en-US")); abbreviations.Abbreviations.Add("hr."); abbreviations.Abbreviations.Add("cont."); #endregion #region "AddResources" template.LanguageResourceBundles.Add(variables); template.LanguageResourceBundles.Add(abbreviations); #endregion #region "save" template.Save(); MessageBox.Show("Unsaved changes? " + template.IsDirty.ToString()); #endregion #region "delete" template.Delete(); #endregion }
private ServerBasedLanguageResourcesTemplate CreateLanguageResouceTemplate() { //check if the template already exists foreach (var item in TMServer.GetLanguageResourcesTemplates(LanguageResourcesTemplateProperties.None)) { if (item.Name == "APISampleTemplate") { return(item); } } //our template doesn't work so create new one ServerBasedLanguageResourcesTemplate template = new ServerBasedLanguageResourcesTemplate(TMServer); template.Name = "APISampleTemplate"; template.LanguageResourceBundles.Add(CreateDefaultBundle(CultureInfo.GetCultureInfo("en-US"))); template.LanguageResourceBundles.Add(CreateDefaultBundle(CultureInfo.GetCultureInfo("de-DE"))); template.ParentResourceGroupPath = ParentOrganizationPath; template.Save(); return(template); }