internal void NotifyTranslationRemoved (Translation tr)
		{
			isDirty = true;
			OnTranslationRemoved (EventArgs.Empty);
		}
		internal void NotifyTranslationAdded (Translation tr)
		{
			if (!Loading)
				isDirty = true; 
			OnTranslationAdded (EventArgs.Empty);
		}
Esempio n. 3
0
        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
                {
                    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.IsCancelRequested)
                {
                    monitor.Log.WriteLine(GettextCatalog.GetString("Operation cancelled."));
                    return;
                }
            }
        }
		public Translation AddNewTranslation (string isoCode, IProgressMonitor monitor)
		{
			try {
				Translation tr = new Translation (this, isoCode);
				translations.Add (tr);
				string templateFile    = Path.Combine (this.BaseDirectory, "messages.po");
				string translationFile = GetFileName (isoCode);
				if (!File.Exists (templateFile)) 
					CreateDefaultCatalog (monitor);
				File.Copy (templateFile, translationFile);
				
				monitor.ReportSuccess (String.Format (GettextCatalog.GetString ("Language '{0}' successfully added."), isoCode));
				monitor.Step (1);
				this.Save (monitor);
				return tr;
			} catch (Exception e) {
				monitor.ReportError (String.Format ( GettextCatalog.GetString ("Language '{0}' could not be added: "), isoCode), e);
				return null;
			} finally {
				monitor.EndTask ();
			}
		}
Esempio n. 5
0
 internal void NotifyTranslationRemoved(Translation tr)
 {
     isDirty = true;
     OnTranslationRemoved(EventArgs.Empty);
 }