public void UpdateTranslations(IProgressMonitor monitor, params Translation[] translations)
        {
            monitor.BeginTask(null, Translations.Count + 1);

            try {
                List <Project> projects = new List <Project> ();
                foreach (Project p in ParentSolution.GetAllProjects())
                {
                    if (IsIncluded(p))
                    {
                        projects.Add(p);
                    }
                }
                monitor.BeginTask(GettextCatalog.GetString("Updating message catalog"), projects.Count);
                CreateDefaultCatalog(monitor);
                monitor.Log.WriteLine(GettextCatalog.GetString("Done"));
            } finally {
                monitor.EndTask();
                monitor.Step(1);
            }
            if (monitor.IsCancelRequested)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Operation cancelled."));
                return;
            }

            Dictionary <string, bool> isIncluded = new Dictionary <string, bool> ();

            foreach (Translation translation in translations)
            {
                isIncluded[translation.IsoCode] = true;
            }
            foreach (Translation translation in this.Translations)
            {
                if (!isIncluded.ContainsKey(translation.IsoCode))
                {
                    continue;
                }
                string poFileName = translation.PoFile;
                monitor.BeginTask(GettextCatalog.GetString("Updating {0}", translation.PoFile), 1);
                try {
                    Runtime.ProcessService.StartProcess("msgmerge",
                                                        " -U \"" + poFileName + "\" -v \"" + Path.Combine(this.BaseDirectory, "messages.po") + "\"",
                                                        this.BaseDirectory,
                                                        monitor.Log,
                                                        monitor.Log,
                                                        null).WaitForOutput();
                } catch (Exception ex) {
                    monitor.ReportError(GettextCatalog.GetString("Could not update file {0}", translation.PoFile), ex);
                } finally {
                    monitor.EndTask();
                    monitor.Step(1);
                }
                if (monitor.IsCancelRequested)
                {
                    monitor.Log.WriteLine(GettextCatalog.GetString("Operation cancelled."));
                    return;
                }
            }
        }
예제 #2
0
 public IList <string> GetUserAssemblyPaths(ConfigurationSelector configuration)
 {
     if (ParentSolution == null)
     {
         return(null);
     }
     //return all projects in the sln in case some are loaded dynamically
     //FIXME: should we do this for the whole workspace?
     return(ParentSolution.GetAllProjects().OfType <DotNetProject> ()
            .Select(d => (string)d.GetOutputFileName(configuration))
            .Where(d => !string.IsNullOrEmpty(d)).ToList());
 }
예제 #3
0
        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"));
        }
예제 #4
0
        public void UpdateTranslations(ProgressMonitor monitor, params Translation[] translations)
        {
            monitor.BeginTask(null, Translations.Count + 1);

            try {
                List <Project> projects = new List <Project> ();
                foreach (Project p in ParentSolution.GetAllProjects())
                {
                    if (IsIncluded(p))
                    {
                        projects.Add(p);
                    }
                }
                monitor.BeginTask(GettextCatalog.GetString("Updating message catalog"), projects.Count);
                CreateDefaultCatalog(monitor);
                monitor.Log.WriteLine(GettextCatalog.GetString("Done"));
            } finally {
                monitor.EndTask();
                monitor.Step(1);
            }
            if (monitor.CancellationToken.IsCancellationRequested)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("Operation cancelled."));
                return;
            }

            Dictionary <string, bool> isIncluded = new Dictionary <string, bool> ();

            foreach (Translation translation in translations)
            {
                isIncluded[translation.IsoCode] = true;
            }
            foreach (Translation translation in this.Translations)
            {
                if (!isIncluded.ContainsKey(translation.IsoCode))
                {
                    continue;
                }
                string poFileName = translation.PoFile;
                monitor.BeginTask(GettextCatalog.GetString("Updating {0}", translation.PoFile), 1);
                try {
                    var pb = new ProcessArgumentBuilder();
                    pb.Add("-U");
                    pb.AddQuoted(poFileName);
                    pb.Add("-v");
                    pb.AddQuoted(this.BaseDirectory.Combine("messages.po"));

                    var process = Runtime.ProcessService.StartProcess(Translation.GetTool("msgmerge"),
                                                                      pb.ToString(), this.BaseDirectory, monitor.Log, monitor.Log, null);
                    process.WaitForOutput();
                }
                catch (System.ComponentModel.Win32Exception) {
                    var msg = GettextCatalog.GetString("Did not find msgmerge. Please ensure that gettext tools are installed.");
                    monitor.ReportError(msg, null);
                }
                catch (Exception ex) {
                    monitor.ReportError(GettextCatalog.GetString("Could not update file {0}", translation.PoFile), ex);
                }
                finally {
                    monitor.EndTask();
                    monitor.Step(1);
                }
                if (monitor.CancellationToken.IsCancellationRequested)
                {
                    monitor.Log.WriteLine(GettextCatalog.GetString("Operation cancelled."));
                    return;
                }
            }
        }