public void RemoveEntry(string msgstr) { foreach (Translation translation in this.Translations) { string poFileName = translation.PoFile; Catalog catalog = new Catalog(this); catalog.Load(new MonoDevelop.Core.ProgressMonitor(), poFileName); CatalogEntry entry = catalog.FindItem(msgstr); if (entry != null) { catalog.RemoveItem(entry); catalog.Save(poFileName); } } }
// Merges the catalog with reference catalog // (in the sense of msgmerge -- this catalog is old one with // translations, \a refcat is reference catalog created by Update().) // return true if the merge was successfull, false otherwise. public bool Merge(IProgressMonitor mon, Catalog refCat) { // TODO: implement via monitor, not in a GUI thread... // But mind about it as it would be used during build. // Or do we want such a feature also for invoking in gui // for po files not in project? string oldName = fileName; string tmpDir = Path.GetTempPath(); string filePrefix = Path.GetFileNameWithoutExtension(Path.GetTempFileName()); string tmp1 = tmpDir + Path.DirectorySeparatorChar + filePrefix + ".ref.pot"; string tmp2 = tmpDir + Path.DirectorySeparatorChar + filePrefix + ".input.po"; string tmp3 = tmpDir + Path.DirectorySeparatorChar + filePrefix + ".output.po"; refCat.Save(tmp1); this.Save(tmp2); System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "msgmerge"; process.StartInfo.Arguments = "--force-po -o \"" + tmp3 + "\" \"" + tmp2 + "\" \"" + tmp1 + "\""; //Console.WriteLine ("--force-po -o \"" + tmp3 + "\" \"" + tmp2 + "\" \"" + tmp1 + "\""); process.Start(); process.WaitForExit(); bool succ = process.ExitCode == 0; if (succ) { Catalog c = new Catalog(parentProj); c.Load(mon, tmp3); Clear(); Append(c); } File.Delete(tmp1); File.Delete(tmp2); File.Delete(tmp3); fileName = oldName; IsDirty = true; return(succ); }
void CreateDefaultCatalog(ProgressMonitor monitor) { IFileScanner[] scanners = TranslationService.GetFileScanners(); Catalog catalog = new Catalog(this); List <Project> projects = new List <Project> (); foreach (Project p in ParentSolution.GetAllProjects()) { if (IsIncluded(p)) { projects.Add(p); } } foreach (Project p in projects) { monitor.Log.WriteLine(GettextCatalog.GetString("Scanning project {0}...", p.Name)); foreach (ProjectFile file in p.Files) { if (!File.Exists(file.FilePath)) { continue; } if (file.Subtype == Subtype.Code) { string mimeType = DesktopService.GetMimeTypeForUri(file.FilePath); foreach (IFileScanner fs in scanners) { if (fs.CanScan(this, catalog, file.FilePath, mimeType)) { fs.UpdateCatalog(this, catalog, monitor, file.FilePath); } } } } if (monitor.CancellationToken.IsCancellationRequested) { return; } monitor.Step(1); } catalog.Save(Path.Combine(this.BaseDirectory, "messages.po")); }