private void AddTermbase(FileBasedProject createdProject, string pathToTermbase, string sourceLang, string targetLang)
        {
            // need to be tested
            TermbaseConfiguration termbaseConfiguration = createdProject.GetTermbaseConfiguration();

            termbaseConfiguration.Termbases.Add(new LocalTermbase(pathToTermbase));

            // change default option - as the options are bit inconsistent please add this to the documentation
            termbaseConfiguration.TermRecognitionOptions.MinimumMatchValue = 60;

            termbaseConfiguration.LanguageIndexes.Add(new TermbaseLanguageIndex(new Language(sourceLang), "Source"));
            termbaseConfiguration.LanguageIndexes.Add(new TermbaseLanguageIndex(new Language(targetLang), "Target"));

            createdProject.UpdateTermbaseConfiguration(termbaseConfiguration);
        }
        private void IncludeTermbaseInStudio(ITermbase termbase, TermbaseGeneration termbaseCreator, string termbasePath)
        {
            ITelemetryTracker telemetryTracker = new TelemetryTracker();

            try
            {
                telemetryTracker.StartTrackRequest("Including the termbase into Trados Studio");
                telemetryTracker.TrackEvent("Including the termbase into Trados Studio", null);

                #region TbConfig
                var project = SdlTradosStudio.Application.GetController <ProjectsController>().CurrentProject;
                TermbaseConfiguration termbaseConfig = project.GetTermbaseConfiguration();
                #endregion

                #region AddTb
                var studioTermbase = new LocalTermbase(termbasePath);
                termbaseConfig.Termbases.Add(studioTermbase);
                #endregion

                #region TermRecOptions
                TermRecognitionOptions options = termbaseConfig.TermRecognitionOptions;
                options.MinimumMatchValue = 50;
                options.SearchDepth       = 200;
                options.ShowWithNoAvailableTranslation = true;
                options.SearchOrder = TermbaseSearchOrder.Hierarchical;
                #endregion

                #region TermbaseLanguageIndex
                var langs = termbaseCreator.GetProjectLanguages();
                termbaseConfig.LanguageIndexes.Clear();
                foreach (var lang in langs.Keys)
                {
                    termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(new Language(CultureInfo.GetCultureInfo(langs[lang])), lang));
                }
                #endregion

                #region UpdateTermbaseConfiguration
                project.UpdateTermbaseConfiguration(termbaseConfig);
                #endregion
            }
            catch (Exception e)
            {
                telemetryTracker.TrackException(new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message));
                telemetryTracker.TrackTrace((new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message)).StackTrace, Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error);
                throw new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message);
            }
        }
Exemple #3
0
        public void AddTermbase(FileBasedProject project, string termbaseFileName)
        {
            #region "TbConfig"
            TermbaseConfiguration termbaseConfig = project.GetTermbaseConfiguration();
            #endregion

            #region "AddTb"
            Termbase tb = new LocalTermbase(termbaseFileName);
            termbaseConfig.Termbases.Add(tb);
            #endregion

            #region "TermRecOptions"
            TermRecognitionOptions options = termbaseConfig.TermRecognitionOptions;
            options.MinimumMatchValue = 50;
            options.SearchDepth       = 200;
            options.ShowWithNoAvailableTranslation = true;
            options.SearchOrder = TermbaseSearchOrder.Hierarchical;
            #endregion

            #region "ProjectLanguagesAndTbIndexes"
            string[] termbaseIndex = { "English", "German", "French" };

            Language projSourceLang  = new Language(CultureInfo.GetCultureInfo("en-US"));
            Language projTargetLang1 = new Language(CultureInfo.GetCultureInfo("de-DE"));
            Language projTargetLang2 = new Language(CultureInfo.GetCultureInfo("fr-FR"));
            #endregion

            #region "TermbaseLanguageIndex"
            termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(projSourceLang, termbaseIndex[0]));
            termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(projTargetLang1, termbaseIndex[1]));
            termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(projTargetLang2, termbaseIndex[2]));
            #endregion

            #region "UpdateTermbaseConfiguration"
            project.UpdateTermbaseConfiguration(termbaseConfig);
            #endregion
        }
        /// <summary>
        /// Merges the terminology databases.
        /// </summary>
        /// <param name="sourceTermbaseConfig">The source terminology database configuration.</param>
        /// <param name="targetTermbaseConfig">The target terminology database configuration.</param>
        private void MergeTermbases(TermbaseConfiguration sourceTermbaseConfig, TermbaseConfiguration targetTermbaseConfig)
        {
            // Look at each termbase in the source project
            foreach (Termbase sourceTermbase in sourceTermbaseConfig.Termbases)
            {
                // Look for a matching termbase in the target project
                bool foundEntry = false;
                foreach (Termbase targetTermbase in targetTermbaseConfig.Termbases)
                {
                    // Detect local or server termbases
                    if (sourceTermbase is LocalTermbase)
                    {
                        // Skip if the file doesn't exist
                        if (!File.Exists((sourceTermbase as LocalTermbase).FilePath))
                        {
                            foundEntry = true;
                            break;
                        }

                        // Must be the same type to match
                        if (targetTermbase is LocalTermbase)
                        {
                            // Match based on file path
                            if ((sourceTermbase as LocalTermbase).FilePath.Equals((targetTermbase as LocalTermbase).FilePath, StringComparison.InvariantCultureIgnoreCase))
                            {
                                foundEntry = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        // If we're dealing with server termbase then we need the same server!
                        if (sourceTermbaseConfig.TermbaseServerUri == targetTermbaseConfig.TermbaseServerUri)
                        {
                            // Must be the same type to match
                            if (targetTermbase is ServerTermbase)
                            {
                                // Match based on name
                                var serverTermbase = sourceTermbase as ServerTermbase;
                                if (serverTermbase != null && serverTermbase.Name.Equals((targetTermbase as ServerTermbase).Name, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    foundEntry = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            // We can't add this one so "pretend" we found it
                            foundEntry = true;
                        }
                    }
                }

                // If we didn't find the current termbase then add it to the target project
                if (!foundEntry)
                {
                    targetTermbaseConfig.Termbases.Add(sourceTermbase);
                }
            }

            // Merge the language indexes
            foreach (TermbaseLanguageIndex sourceLanguageIndex in sourceTermbaseConfig.LanguageIndexes)
            {
                bool foundIndex = targetTermbaseConfig.LanguageIndexes.Any(targetLanguageIndex => sourceLanguageIndex.ProjectLanguage.Equals(targetLanguageIndex.ProjectLanguage));

                // If we didn't find an entry for this language then add it to the target project
                if (!foundIndex)
                {
                    targetTermbaseConfig.LanguageIndexes.Add(sourceLanguageIndex);
                }
            }
        }
        /// <summary>
        /// Executes this instance.
        /// </summary>
        protected override void Execute()
        {
            string          grammarCheckerSettingsId      = "GrammarCheckerSettings";
            string          numberVerifierSettingsId      = "NumberVerifierSettings";
            IExtensionPoint globalVerifiersExtensionPoint = PluginManager.DefaultPluginRegistry.GetExtensionPoint <GlobalVerifierAttribute>();

            foreach (IExtension extension in globalVerifiersExtensionPoint.Extensions)
            {
                IGlobalVerifier globalVerifier  = (IGlobalVerifier)extension.CreateInstance();
                string          settingsGroupId = globalVerifier.SettingsId;
                if (settingsGroupId.Contains("Grammar"))
                {
                    grammarCheckerSettingsId = settingsGroupId;
                }

                if (settingsGroupId.Contains("Number"))
                {
                    numberVerifierSettingsId = settingsGroupId;
                }
            }

            // Show the dialog
            ApplyTemplateForm applyTemplateForm = new ApplyTemplateForm(Controller);

            if (applyTemplateForm.ShowDialog() == DialogResult.OK)
            {
                // This is the template that the user selected
                ApplyTemplate selectedTemplate = applyTemplateForm.ActiveTemplate;

                // Create list of projects
                List <FileBasedProject> selectedProjects = new List <FileBasedProject>();
                if (applyTemplateForm.ApplyToSelected)
                {
                    selectedProjects.AddRange(Controller.SelectedProjects);
                }
                else
                {
                    if (Controller.CurrentProject != null)
                    {
                        selectedProjects.Add(Controller.CurrentProject);
                    }
                }

                // Check if we have any projects
                if (selectedProjects.Count == 0)
                {
                    MessageBox.Show(applyTemplateForm.ApplyToSelected ? PluginResources.No_Projects_Selected : PluginResources.No_Current_Project, PluginResources.Plugin_Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Work through all projects
                StringBuilder projectsList = new StringBuilder();
                projectsList.AppendLine(PluginResources.Settings_Applied);
                foreach (FileBasedProject targetProject in selectedProjects)
                {
                    // Temporary folder path
                    string tempFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));

                    // This is the current project and it's related information
                    ProjectInfo targetProjectInfo = targetProject.GetProjectInfo();
                    projectsList.AppendLine(targetProjectInfo.Name);
                    ISettingsBundle targetSettingsBundle = targetProject.GetSettings();

                    // This is the source project - check if it's a loaded one
                    FileBasedProject sourceProject = Controller.GetAllProjects().FirstOrDefault(loadedProject => String.Compare(loadedProject.FilePath, selectedTemplate.FileLocation, StringComparison.OrdinalIgnoreCase) == 0);

                    // Not found so load it from the filing system
                    if (sourceProject == null)
                    {
                        if (string.IsNullOrEmpty(selectedTemplate.FileLocation))
                        {
                            if (selectedTemplate.Id != Guid.Empty)
                            {
                                // Create a new project based on a template configured in Studio
                                ProjectTemplateReference projectTemplate = new ProjectTemplateReference(selectedTemplate.Uri);
                                string savedFolder = targetProjectInfo.LocalProjectFolder;
                                targetProjectInfo.LocalProjectFolder = tempFolder;
                                sourceProject = new FileBasedProject(targetProjectInfo, projectTemplate);
                                targetProjectInfo.LocalProjectFolder = savedFolder;
                            }
                        }
                        else
                        {
                            if (Path.GetExtension(selectedTemplate.FileLocation).ToLowerInvariant() == ".sdltpl")
                            {
                                // Create a new project based on a file-based template
                                ProjectTemplateReference projectTemplate = new ProjectTemplateReference(selectedTemplate.FileLocation);
                                string savedFolder = targetProjectInfo.LocalProjectFolder;
                                targetProjectInfo.LocalProjectFolder = tempFolder;
                                sourceProject = new FileBasedProject(targetProjectInfo, projectTemplate);
                                targetProjectInfo.LocalProjectFolder = savedFolder;
                            }
                            else
                            {
                                // Load a project from the filing system
                                sourceProject = new FileBasedProject(selectedTemplate.FileLocation);
                            }
                        }
                    }

                    // Get the information from the source project
                    ProjectInfo     sourceProjectInfo    = sourceProject.GetProjectInfo();
                    ISettingsBundle sourceSettingsBundle = sourceProject.GetSettings();

                    // Copy all languages translation providers
                    if (selectedTemplate.TranslationProvidersAllLanguages != ApplyTemplateOptions.Keep)
                    {
                        try
                        {
                            // Update the "all languages" node
                            TranslationProviderConfiguration sourceProviderConfig = sourceProject.GetTranslationProviderConfiguration();
                            if (selectedTemplate.TranslationProvidersAllLanguages == ApplyTemplateOptions.Merge)
                            {
                                TranslationProviderConfiguration targetProviderConfig = targetProject.GetTranslationProviderConfiguration();
                                MergeTranslationProviders(sourceProviderConfig, targetProviderConfig);
                                ValidateTranslationProviderConfiguration(targetProviderConfig);
                                targetProject.UpdateTranslationProviderConfiguration(targetProviderConfig);
                            }
                            else
                            {
                                ValidateTranslationProviderConfiguration(sourceProviderConfig);
                                targetProject.UpdateTranslationProviderConfiguration(sourceProviderConfig);
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.TPAL_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy language-specific translation providers
                    if (selectedTemplate.TranslationProvidersSpecificLanguages != ApplyTemplateOptions.Keep)
                    {
                        if (sourceProjectInfo.SourceLanguage.Equals(targetProjectInfo.SourceLanguage))
                        {
                            foreach (Language sourceTargetLanguage in sourceProjectInfo.TargetLanguages)
                            {
                                foreach (Language targetTargetLanguage in targetProjectInfo.TargetLanguages)
                                {
                                    if (sourceTargetLanguage.Equals(targetTargetLanguage))
                                    {
                                        try
                                        {
                                            // Copy translation providers
                                            TranslationProviderConfiguration sourceProviderConfig = sourceProject.GetTranslationProviderConfiguration(sourceTargetLanguage);
                                            if (selectedTemplate.TranslationProvidersSpecificLanguages == ApplyTemplateOptions.Merge)
                                            {
                                                TranslationProviderConfiguration targetProviderConfig = targetProject.GetTranslationProviderConfiguration(targetTargetLanguage);
                                                MergeTranslationProviders(sourceProviderConfig, targetProviderConfig);
                                                ValidateTranslationProviderConfiguration(targetProviderConfig);
                                                targetProject.UpdateTranslationProviderConfiguration(targetTargetLanguage, targetProviderConfig);
                                            }
                                            else
                                            {
                                                ValidateTranslationProviderConfiguration(sourceProviderConfig);
                                                targetProject.UpdateTranslationProviderConfiguration(targetTargetLanguage, sourceProviderConfig);
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                            MessageBox.Show(e.Message, string.Format(PluginResources.TPSL_Failed, targetTargetLanguage.DisplayName), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Copy TM settings for all languages
                    if (selectedTemplate.TranslationMemoriesAllLanguages == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            // Update the translation memory filter settings
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "TranslationMemorySettings", targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.TMAL_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy TM settings for specific languages
                    if (selectedTemplate.TranslationMemoriesSpecificLanguages == ApplyTemplateOptions.Overwrite)
                    {
                        if (sourceProjectInfo.SourceLanguage.Equals(targetProjectInfo.SourceLanguage))
                        {
                            foreach (Language sourceTargetLanguage in sourceProjectInfo.TargetLanguages)
                            {
                                foreach (Language targetTargetLanguage in targetProjectInfo.TargetLanguages)
                                {
                                    if (sourceTargetLanguage.Equals(targetTargetLanguage))
                                    {
                                        try
                                        {
                                            // Now copy translation memory settings - different section
                                            ISettingsBundle sourceTmSettings = sourceProject.GetSettings(sourceTargetLanguage);
                                            ISettingsBundle targetTmSettings = targetProject.GetSettings(targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "TranslationMemorySettings", targetProject, targetTargetLanguage);
                                        }
                                        catch (Exception e)
                                        {
                                            MessageBox.Show(e.Message, string.Format(PluginResources.TMSL_Failed, targetTargetLanguage.DisplayName), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Copy terminology termbases
                    if (selectedTemplate.TerminologyTermbases != ApplyTemplateOptions.Keep)
                    {
                        TermbaseConfiguration sourceTermbaseConfig = sourceProject.GetTermbaseConfiguration();
                        TermbaseConfiguration targetTermbaseConfig = targetProject.GetTermbaseConfiguration();

                        if (selectedTemplate.TerminologyTermbases == ApplyTemplateOptions.Merge)
                        {
                            MergeTermbases(sourceTermbaseConfig, targetTermbaseConfig);
                        }
                        else
                        {
                            targetTermbaseConfig.TermbaseServerUri = sourceTermbaseConfig.TermbaseServerUri;
                            targetTermbaseConfig.Termbases.Clear();
                            targetTermbaseConfig.LanguageIndexes.Clear();
                            MergeTermbases(sourceTermbaseConfig, targetTermbaseConfig);
                        }

                        // Updating with zero termbases throws an exception
                        if (targetTermbaseConfig.Termbases.Count > 0)
                        {
                            try
                            {
                                targetProject.UpdateTermbaseConfiguration(targetTermbaseConfig);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message, PluginResources.TBTB_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }

                    // Copy terminology settings
                    if (selectedTemplate.TerminologySearchSettings == ApplyTemplateOptions.Overwrite)
                    {
                        TermbaseConfiguration sourceTermbaseConfig = sourceProject.GetTermbaseConfiguration();
                        TermbaseConfiguration targetTermbaseConfig = targetProject.GetTermbaseConfiguration();
                        targetTermbaseConfig.TermRecognitionOptions = sourceTermbaseConfig.TermRecognitionOptions;

                        // Updating with zero termbases throws an exception
                        if (targetTermbaseConfig.Termbases.Count > 0)
                        {
                            try
                            {
                                targetProject.UpdateTermbaseConfiguration(targetTermbaseConfig);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.Message, PluginResources.TBSS_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }

                    // Copy QA verification settings where applicable
                    if (selectedTemplate.VerificationQaChecker30 == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "QAVerificationSettings", targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.QAQA_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy tag verification settings where applicable
                    if (selectedTemplate.VerificationTagVerifier == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "SettingsTagVerifier", targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.QATG_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy term verification settings where applicable
                    if (selectedTemplate.VerificationTerminologyVerifier == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "SettingsTermVerifier", targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.QATV_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy number verification settings where applicable
                    if (selectedTemplate.VerificationNumberVerifier == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, numberVerifierSettingsId, targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.QANV_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy grammar checking settings where applicable
                    if (selectedTemplate.VerificationGrammarChecker == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, grammarCheckerSettingsId, targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.QAGC_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy file type settings where applicable
                    if (selectedTemplate.FileTypes == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            var copiedTypes = new List <string>();
                            foreach (ProjectFile projectFile in targetProject.GetTargetLanguageFiles())
                            {
                                if (!copiedTypes.Contains(projectFile.FileTypeId))
                                {
                                    copiedTypes.Add(projectFile.FileTypeId);
                                    CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, projectFile.FileTypeId, targetProject, null);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.FTTS_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    // Copy batch tasks settings where applicable
                    if (selectedTemplate.BatchTasksAllLanguages == ApplyTemplateOptions.Overwrite)
                    {
                        try
                        {
                            // Update the translation memory filter settings
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "PseudoTranslateSettings", targetProject, null);
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "AnalysisTaskSettings", targetProject, null);
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "VerificationSettings", targetProject, null);
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "TranslateTaskSettings", targetProject, null);
                            CopySettingsGroup(sourceSettingsBundle, targetSettingsBundle, "TranslationMemoryUpdateTaskSettings", targetProject, null);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, PluginResources.BTAL_Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    if (selectedTemplate.BatchTasksSpecificLanguages == ApplyTemplateOptions.Overwrite)
                    {
                        // Update specific language pairs where possible
                        if (sourceProjectInfo.SourceLanguage.Equals(targetProjectInfo.SourceLanguage))
                        {
                            foreach (Language sourceTargetLanguage in sourceProjectInfo.TargetLanguages)
                            {
                                foreach (Language targetTargetLanguage in targetProjectInfo.TargetLanguages)
                                {
                                    if (sourceTargetLanguage.Equals(targetTargetLanguage))
                                    {
                                        try
                                        {
                                            // Now copy translation memory settings - different section
                                            ISettingsBundle sourceTmSettings = sourceProject.GetSettings(sourceTargetLanguage);
                                            ISettingsBundle targetTmSettings = targetProject.GetSettings(targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "PseudoTranslateSettings", targetProject, targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "AnalysisTaskSettings", targetProject, targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "VerificationSettings", targetProject, targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "TranslateTaskSettings", targetProject, targetTargetLanguage);
                                            CopySettingsGroup(sourceTmSettings, targetTmSettings, "TranslationMemoryUpdateTaskSettings", targetProject, targetTargetLanguage);
                                        }
                                        catch (Exception e)
                                        {
                                            MessageBox.Show(e.Message, string.Format(PluginResources.BTSL_Failed, targetTargetLanguage.DisplayName), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Remove the temporary folder if it exists
                    if (Directory.Exists(tempFolder))
                    {
                        Directory.Delete(tempFolder, true);
                    }

                    // Use reflection to synch the project to the server
                    try
                    {
                        var project = typeof(FileBasedProject).GetField("_project", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(targetProject);
                        project.GetType().GetMethod("UpdateServerProjectSettings").Invoke(project, null);
                    }
                    catch
                    {
                    }
                }

                // Tell the user we're done
                MessageBox.Show(projectsList.ToString(), PluginResources.Plugin_Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            // Save the project templates anyway
            applyTemplateForm.SaveProjectTemplates();
        }