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); }
// Updates the catalog from POT file. public bool UpdateFromPOT(IProgressMonitor mon, string potFile, bool summary) { if (!isOk) { return(false); } Catalog newCat = new Catalog(parentProj); newCat.Load(mon, potFile); if (!newCat.IsOk) { return(false); } // TODO: add some interactivity //if (! summary) //|| ShowMergeSummary (newcat) return(Merge(mon, newCat)); //else // return false; }