public void SafeRemoveInputTmxFile(InputTmxFile tmxFile) { Application.Current.Dispatcher.Invoke(new Action(() => { InputTmxFiles.Remove(tmxFile); })); }
private void SafeAddInputTmxFile(InputTmxFile tmxFile) { Application.Current.Dispatcher.Invoke(new Action(() => { InputTmxFiles.Add(tmxFile); })); }
/// <summary> /// Validates the input sources (TMX and optional TM) /// </summary> /// <returns></returns> public bool ValidateInput() { int totalTuCount = 0; FileBasedTranslationMemory tm = null; if (UseExistingTranslationMemory) { if (InputTranslationMemory == null || String.IsNullOrEmpty(InputTranslationMemory.FilePath)) { ShowError("Select the Studio translation memory to clean up."); return(false); } try { // try to access the TM tm = InputTranslationMemory.TranslationMemory; totalTuCount += tm.LanguageDirection.GetTranslationUnitCount(); } catch (Exception ex) { ShowError("Failed to open the translation memory: \r\n" + ex.ToString()); return(false); } } if (InputTmxFiles.Count == 0) { ShowError("Select at least one input TMX file."); return(false); } if (InputTmxFiles.Any(f => f.TmxFile.IsDetecting)) { ShowError("Please wait while the TMX files are being analyzed."); return(false); } if (InputTmxFiles.Any(f => f.TmxFile.DetectInfo.DetectedVersion != DetectInfo.Versions.Workbench)) { ShowError("One or more TMX files are not Workbench export files."); return(false); } if (InputTmxFiles.Any(f => f.TmxFile.DetectInfo == null || f.TmxFile.DetectInfo.SourceLanguage == null || f.TmxFile.DetectInfo.TargetLanguage == null)) { ShowError("The source and target language of one or more TMX files could not be detected. Make sure the TMX file is valid or remove it from the list."); return(false); } CultureInfo sourceCulture = tm != null ? tm.LanguageDirection.SourceLanguage : InputTmxFiles.First().TmxFile.DetectInfo.SourceLanguage.CultureInfo; CultureInfo targetCulture = tm != null ? tm.LanguageDirection.TargetLanguage : InputTmxFiles.First().TmxFile.DetectInfo.TargetLanguage.CultureInfo; foreach (InputTmxFile f in InputTmxFiles) { if (!CultureInfoExtensions.AreCompatible(f.TmxFile.DetectInfo.SourceLanguage.CultureInfo, sourceCulture) || !CultureInfoExtensions.AreCompatible(f.TmxFile.DetectInfo.TargetLanguage.CultureInfo, targetCulture)) { ShowError("Make sure all the selected TMX files have compatible languages. The main language has to match."); return(false); } totalTuCount += f.TmxFile.GetDetectInfo().TuCount; } SourceLanguage = new Language(sourceCulture); TargetLanguage = new Language(targetCulture); return(true); }