protected override async void Execute() { _shouldExit = false; var projects = GetProjectsController().SelectedProjects; var editorController = GetEditorController(); editorController.Closing += EditorController_Closing; var userCredentials = Helpers.Credentials.GetCredentials(); if (userCredentials != null) { var userDetails = await ApiClient.Login(userCredentials.Email, userCredentials.Password); await ApiClient.OosSession(userCredentials, userDetails.Sid); var providerUrl = string.Empty; foreach (var project in projects) { _processedFilesList.Clear(); var providerExist = false; var provider = project.GetTranslationProviderConfiguration(); foreach (var entry in provider.Entries) { if (entry.MainTranslationProvider.Enabled && entry.MainTranslationProvider.Uri.AbsoluteUri.Contains("bmslanguagecloud")) { providerExist = true; providerUrl = HttpUtility.UrlDecode(HttpUtility.UrlDecode(entry.MainTranslationProvider.Uri.AbsoluteUri)); break; } } if (providerExist) { var files = project.GetTargetLanguageFiles(); var providersDetails = EngineDetails.GetDetailsFromEngineUrl(providerUrl); using (var waitForm = new WaitForm()) { waitForm.Show(); await ProcessFiles(files, providersDetails, userDetails); waitForm.Close(); } } } } }
protected override async void Execute() { var editorController = GetEditorController(); var projects = GetProjectsController().SelectedProjects; var userCredentials = Helpers.Credentials.GetCredentials(); if (userCredentials != null) { var userDetails = await ApiClient.Login(userCredentials.Email, userCredentials.Password); await ApiClient.OosSession(userCredentials, userDetails.Sid); var providerUrl = string.Empty; foreach (var project in projects) { var providerExist = false; var provider = project.GetTranslationProviderConfiguration(); foreach (var entry in provider.Entries) { if (entry.MainTranslationProvider.Enabled && entry.MainTranslationProvider.Uri.AbsoluteUri.Contains("bmslanguagecloud")) { providerExist = true; providerUrl = HttpUtility.UrlDecode(HttpUtility.UrlDecode(entry.MainTranslationProvider.Uri.AbsoluteUri)); break; //for the moment we take only the first cloud provider } } if (providerExist) { var files = project.GetTargetLanguageFiles(); var providersDetails = EngineDetails.GetDetailsFromEngineUrl(providerUrl); foreach (var file in files) { var targetLanguage = file.Language.IsoAbbreviation; var document = editorController.Open(file, EditingMode.Translation); var segmentPairs = document.SegmentPairs.ToList(); var providerDetails = providersDetails.FirstOrDefault(t => t.TargetLang.Equals(targetLanguage)); if (providerDetails != null) { providerDetails.SourceLang = file.SourceFile.Language.IsoAbbreviation; //Confirm each segment foreach (var segmentPair in segmentPairs) { if (segmentPair.Target.ToString() != string.Empty) { var feedbackRequest = Helpers.Api.CreateFeedbackRequest(segmentPair, providerDetails); var feedbackReaponse = await ApiClient.Feedback(userDetails.Sid, feedbackRequest); if (feedbackReaponse.Success) { segmentPair.Properties.ConfirmationLevel = ConfirmationLevel.Translated; editorController.ActiveDocument.UpdateSegmentPairProperties(segmentPair, segmentPair.Properties); } } } } project.Save(); } } } } }