public TranslationProjectOptionsDialog (TranslationProject project)
		{
			this.project = project;
			this.Build();
			
			entryPackageName.Text        = project.PackageName;
			entryRelPath.Text            = project.RelPath;
			radiobuttonRelPath.Active    = project.OutputType == TranslationOutputType.RelativeToOutput;
			radiobuttonSystemPath.Active = project.OutputType == TranslationOutputType.SystemPath;
			
			entryPackageName.Changed += new EventHandler (UpdateInitString);
			entryRelPath.Changed += new EventHandler (UpdateInitString);
			radiobuttonRelPath.Activated += new EventHandler (UpdateInitString);
			radiobuttonSystemPath.Activated += new EventHandler (UpdateInitString);
			
			UpdateInitString (this, EventArgs.Empty);
			this.buttonOk.Clicked += delegate {
				project.PackageName = entryPackageName.Text;
				project.RelPath = entryRelPath.Text;
				if (radiobuttonRelPath.Active) {
					project.OutputType = TranslationOutputType.RelativeToOutput;
				} else {
					project.OutputType = TranslationOutputType.SystemPath;
				}
				this.Destroy ();
			};
			this.buttonCancel.Clicked += delegate {
				this.Destroy ();
			};
			
			store = new TreeStore (typeof(string), typeof(bool), typeof(string), typeof(SolutionFolderItem), typeof(bool));
			treeviewProjectList.Model = store;
			treeviewProjectList.HeadersVisible = false;
			
			TreeViewColumn col = new TreeViewColumn ();
			
			CellRendererToggle cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Toggled += new ToggledHandler (ActiveToggled);
			cellRendererToggle.Activatable = true;
			col.PackStart (cellRendererToggle, false);
			col.AddAttribute (cellRendererToggle, "active", 1);
			col.AddAttribute (cellRendererToggle, "visible", 4);
			
			CellRendererImage crp = new CellRendererImage ();
			col.PackStart (crp, false);
			col.AddAttribute (crp, "stock_id", 0);
			
			CellRendererText crt = new CellRendererText ();
			col.PackStart (crt, true);
			col.AddAttribute (crt, "text", 2);
			
			treeviewProjectList.AppendColumn (col);
			
			FillTree (TreeIter.Zero, project.ParentSolution.RootFolder);
		}
Exemplo n.º 2
0
        // Creates new, empty header. Sets Charset to something meaningful ("UTF-8", currently).
        void CreateNewHeaders(TranslationProject project)
        {
            RevisionDate = CreationDate = Catalog.GetDateTimeRfc822Format();

            Language = Country = Project = Team = TeamEmail = "";

            Charset = "utf-8";
            AuthorInformation userInfo = IdeApp.Workspace.GetAuthorInformation(project);

            Translator      = userInfo.Name;
            TranslatorEmail = userInfo.Email;

            //dt.SourceCodeCharset = String.Empty;
            UpdateHeaderDict();
        }
Exemplo n.º 3
0
        public bool CanScan(TranslationProject project, Catalog catalog, string fileName, string mimeType)
        {
            if (extensions.Count == 0 && mimeTypes.Count == 0)
            {
                return(true);
            }
            string ext = Path.GetExtension(fileName);

            if (ext.Length > 0)
            {
                ext = ext.Substring(1);                              // remove initial dot
            }
            bool r = extensions.Contains(ext) || mimeTypes.Contains(mimeType);

            return(r);
        }
Exemplo n.º 4
0
        // Creates new, empty header. Sets Charset to something meaningful ("UTF-8", currently).
        void CreateNewHeaders(TranslationProject project)
        {
            if (project == null)
            {
                return;
            }
            RevisionDate = CreationDate = Catalog.GetDateTimeRfc822Format();

            Language = Country = Project = Team = TeamEmail = "";

            Charset = "utf-8";
            AuthorInformation userInfo = project.AuthorInformation;

            Translator      = userInfo.Name;
            TranslatorEmail = userInfo.Email;

            //dt.SourceCodeCharset = String.Empty;
            UpdateHeaderDict();
        }
		public void ApplyFeature (SolutionFolder parentCombine, SolutionItem entry)
		{
			TranslationProject newProject;
			if (entry is TranslationProject)
				newProject = (TranslationProject) entry;
			else {
				newProject = new TranslationProject ();
				newProject.Name = entry.Name + "Translation";
				string path = System.IO.Path.Combine (parentCombine.BaseDirectory, newProject.Name);
				if (!System.IO.Directory.Exists (path))
					System.IO.Directory.CreateDirectory (path);
				newProject.FileName = System.IO.Path.Combine (path, newProject.Name + ".mdse");
				parentCombine.Items.Add (newProject);
			}
			
			TreeIter iter;
			if (store.GetIterFirst (out iter)) {
				do {
					string code = (string)store.GetValue (iter, 1);
					newProject.AddNewTranslation (code, new NullProgressMonitor ());
				} while (store.IterNext (ref iter));
			}
		}
Exemplo n.º 6
0
		internal Translation (TranslationProject prj, string isoCode)
		{
			this.parentProject = prj;
			this.isoCode = isoCode;
		}
Exemplo n.º 7
0
        public async Task <int> Run(string[] arguments)
        {
            DesktopService.Initialize();

            Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Gettext Update Tool"));
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("gettext-update [options] [project-file]");
                Console.WriteLine("--f --file:FILE   Project or solution file to build.");
                Console.WriteLine("--p --project:PROJECT  Name of the project to build.");
                Console.WriteLine("--sort  Sorts the output po file");
                Console.WriteLine();
                return(0);
            }

            if (file == null)
            {
                var files = Directory.EnumerateFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        file = f;
                        break;
                    }
                }
                if (file == null)
                {
                    Console.WriteLine("Solution file not found.");
                    return(1);
                }
            }
            else if (!Services.ProjectService.IsWorkspaceItemFile(file))
            {
                Console.WriteLine("File '{0}' is not a project or solution.", file);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;

            WorkspaceItem centry = await Services.ProjectService.ReadWorkspaceItem(monitor, file);

            monitor.IgnoreLogMessages = false;

            Solution solution = centry as Solution;

            if (solution == null)
            {
                Console.WriteLine("File is not a solution: " + file);
                return(1);
            }

            if (project != null)
            {
                SolutionItem item = solution.FindProjectByName(project);

                if (item == null)
                {
                    Console.WriteLine("The project '" + project + "' could not be found in " + file);
                    return(1);
                }
                TranslationProject tp = item as TranslationProject;
                if (tp == null)
                {
                    Console.WriteLine("The project '" + item.FileName + "' is not a translation project");
                    return(1);
                }
                tp.UpdateTranslations(monitor, sort);
            }
            else
            {
                foreach (TranslationProject p in solution.GetAllItems <TranslationProject>())
                {
                    p.UpdateTranslations(monitor, sort);
                }
            }

            return(0);
        }
Exemplo n.º 8
0
 // Expecting iso-8859-1 encoding
 public CharsetInfoFinder(TranslationProject project, string poFile)
     : base(poFile, Encoding.GetEncoding("iso-8859-1"))
 {
     this.project = project;
     charset      = "iso-8859-1";
 }
Exemplo n.º 9
0
		public POEditorWidget (TranslationProject project)
		{
			this.project = project;
			this.Build ();
			
			//FIXME: avoid unnecessary creation of old treeview
			scrolledwindow1.Remove (treeviewEntries);
			treeviewEntries.Destroy ();
			treeviewEntries = new MonoDevelop.Components.ContextMenuTreeView ();
			treeviewEntries.ShowAll ();
			scrolledwindow1.Add (treeviewEntries);
			((MonoDevelop.Components.ContextMenuTreeView)treeviewEntries).DoPopupMenu = ShowPopup;
			
			this.headersEditor = new CatalogHeadersWidget ();
			this.notebookPages.AppendPage (headersEditor, new Gtk.Label ());
			
			updateTaskThread = new BackgroundWorker ();
			updateTaskThread.WorkerSupportsCancellation = true;
			updateTaskThread.DoWork += TaskUpdateWorker;
			
			AddButton (GettextCatalog.GetString ("Translation")).Active = true;
			AddButton (GettextCatalog.GetString ("Headers")).Active = false;
			
			// entries tree view 
			store = new ListStore (typeof(CatalogEntry));
			this.treeviewEntries.Model = store;
			
			TreeViewColumn fuzzyColumn = new TreeViewColumn ();
			fuzzyColumn.SortIndicator = true;
			fuzzyColumn.SortColumnId = 0;
				
			fuzzyColumn.Title = GettextCatalog.GetString ("Fuzzy");
			var iconRenderer = new CellRendererImage ();
			fuzzyColumn.PackStart (iconRenderer, false);
			fuzzyColumn.SetCellDataFunc (iconRenderer, CatalogIconDataFunc);
			
			CellRendererToggle cellRendFuzzy = new CellRendererToggle ();
			cellRendFuzzy.Activatable = true;
			cellRendFuzzy.Toggled += HandleCellRendFuzzyToggled;
			fuzzyColumn.PackStart (cellRendFuzzy, false);
			fuzzyColumn.SetCellDataFunc (cellRendFuzzy, FuzzyToggleDataFunc);
			treeviewEntries.AppendColumn (fuzzyColumn);
			
			TreeViewColumn originalColumn = new TreeViewColumn ();
			originalColumn.Expand = true;
			originalColumn.SortIndicator = true;
			originalColumn.SortColumnId = 1;
			originalColumn.Title = GettextCatalog.GetString ("Original string");
			CellRendererText original = new CellRendererText ();
			original.Ellipsize = Pango.EllipsizeMode.End;
			originalColumn.PackStart (original, true);
			originalColumn.SetCellDataFunc (original, OriginalTextDataFunc);
			treeviewEntries.AppendColumn (originalColumn);
			
			TreeViewColumn translatedColumn = new TreeViewColumn ();
			translatedColumn.Expand = true;
			translatedColumn.SortIndicator = true;
			translatedColumn.SortColumnId = 2;
			translatedColumn.Title = GettextCatalog.GetString ("Translated string");
			CellRendererText translation = new CellRendererText ();
			translation.Ellipsize = Pango.EllipsizeMode.End;
			translatedColumn.PackStart (translation, true);
			translatedColumn.SetCellDataFunc (translation, TranslationTextDataFunc);
			treeviewEntries.AppendColumn (translatedColumn);
			
			treeviewEntries.Selection.Changed += OnEntrySelected;
			
			// found in tree view
			foundInStore = new ListStore (typeof(string), typeof(string), typeof(string), typeof(Xwt.Drawing.Image));
			this.treeviewFoundIn.Model = foundInStore;
			
			TreeViewColumn fileColumn = new TreeViewColumn ();
			var pixbufRenderer = new CellRendererImage ();
			fileColumn.PackStart (pixbufRenderer, false);
			fileColumn.SetAttributes (pixbufRenderer, "image", FoundInColumns.Pixbuf);
			
			CellRendererText textRenderer = new CellRendererText ();
			fileColumn.PackStart (textRenderer, true);
			fileColumn.SetAttributes (textRenderer, "text", FoundInColumns.File);
			treeviewFoundIn.AppendColumn (fileColumn);
			
			treeviewFoundIn.AppendColumn ("", new CellRendererText (), "text", FoundInColumns.Line);
			treeviewFoundIn.HeadersVisible = false;
			treeviewFoundIn.GetColumn (1).FixedWidth = 100;
			
			treeviewFoundIn.RowActivated += delegate(object sender, RowActivatedArgs e) {
				Gtk.TreeIter iter;
				foundInStore.GetIter (out iter, e.Path);
				string line = foundInStore.GetValue (iter, (int)FoundInColumns.Line) as string;
				string file = foundInStore.GetValue (iter, (int)FoundInColumns.FullFileName) as string;
				int lineNr = 1;
				try {
					lineNr = 1 + int.Parse (line);
				} catch {
				}
				IdeApp.Workbench.OpenDocument (file, lineNr, 1);
			};
			this.notebookTranslated.RemovePage (0);
			this.searchEntryFilter.Entry.Text = "";
			searchEntryFilter.Entry.Changed += delegate {
				UpdateFromCatalog ();
			};
			
			this.togglebuttonFuzzy.Active = PropertyService.Get ("Gettext.ShowFuzzy", true);
			this.togglebuttonFuzzy.TooltipText = GettextCatalog.GetString ("Show fuzzy translations");
			this.togglebuttonFuzzy.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowFuzzy", this.togglebuttonFuzzy.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonMissing.Active = PropertyService.Get ("Gettext.ShowMissing", true);
			this.togglebuttonMissing.TooltipText = GettextCatalog.GetString ("Show missing translations");
			this.togglebuttonMissing.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowMissing", this.togglebuttonMissing.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonOk.Active = PropertyService.Get ("Gettext.ShowTranslated", true);
			this.togglebuttonOk.TooltipText = GettextCatalog.GetString ("Show valid translations");
			this.togglebuttonOk.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowTranslated", this.togglebuttonOk.Active);
				UpdateFromCatalog ();
			};
			
			this.textviewComments.Buffer.Changed += delegate {
				if (this.isUpdating)
					return;
				if (this.currentEntry != null) {
					string[] lines =  textviewComments.Buffer.Text.Split (CatalogParser.LineSplitStrings, System.StringSplitOptions.None);
					for (int i = 0; i < lines.Length; i++) {
						if (!lines[i].StartsWith ("#"))
							lines[i] = "# " + lines[i];
					}
					this.currentEntry.Comment = string.Join (System.Environment.NewLine, lines);
				}
				UpdateProgressBar ();
			};
			
			searchEntryFilter.Ready = true;
			searchEntryFilter.Visible = true;
			searchEntryFilter.ForceFilterButtonVisible = true;
			searchEntryFilter.RequestMenu += delegate {
				searchEntryFilter.Menu = CreateOptionsMenu ();
			};
			
			widgets.Add (this);
			
			checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;
			options.ShowLineNumberMargin = false;
			options.ShowFoldMargin = false;
			options.ShowIconMargin = false;
			options.ColorScheme = IdeApp.Preferences.ColorScheme;
			options.FontName = PropertyService.Get<string> ("FontName");
			
			this.scrolledwindowOriginal.Child = this.texteditorOriginal;
			this.scrolledwindowPlural.Child = this.texteditorPlural;
			this.texteditorOriginal.Show ();
			this.texteditorPlural.Show ();
			texteditorOriginal.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			texteditorPlural.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			this.texteditorOriginal.Options = options;
			this.texteditorPlural.Options = options;
			this.texteditorOriginal.Document.ReadOnly = true;
			this.texteditorPlural.Document.ReadOnly = true;
		}
Exemplo n.º 10
0
        public virtual void UpdateCatalog(TranslationProject project, Catalog catalog, ProgressMonitor monitor, string fileName)
        {
            string text             = File.ReadAllText(fileName);
            string relativeFileName = MonoDevelop.Core.FileService.AbsoluteToRelativePath(project.BaseDirectory, fileName);
            string fileNamePrefix   = relativeFileName + ":";

            if (String.IsNullOrEmpty(text))
            {
                return;
            }

            // Get a list of all excluded regions
            List <Match> excludeMatches = new List <Match> ();

            foreach (Regex regex in excluded)
            {
                foreach (Match m in regex.Matches(text))
                {
                    excludeMatches.Add(m);
                }
            }

            // Sort the list by match index
            excludeMatches.Sort(delegate(Match a, Match b) {
                return(a.Index.CompareTo(b.Index));
            });

            // Remove from the list all regions which start in an excluded region
            int pos = 0;

            for (int n = 0; n < excludeMatches.Count; n++)
            {
                Match m = excludeMatches [n];
                if (m.Index < pos)
                {
                    excludeMatches.RemoveAt(n);
                    n--;
                }
                else
                {
                    pos = m.Index + m.Length;
                }
            }

            foreach (RegexInfo ri in regexes)
            {
                int lineNumber = 0;
                int oldIndex   = 0;
                foreach (Match match in ri.Regex.Matches(text))
                {
                    // Ignore matches inside excluded regions
                    bool ignore = false;
                    foreach (Match em in excludeMatches)
                    {
                        if (match.Index >= em.Index && match.Index < em.Index + em.Length)
                        {
                            ignore = true;
                            LoggingService.LogDebug("Excluded Gettext string '{0}' in file '{1}'", match.Groups[ri.ValueGroupIndex].Value, fileName);
                            break;
                        }
                    }
                    if (ignore)
                    {
                        continue;
                    }

                    string mt = match.Groups[ri.ValueGroupIndex].Value;
                    if (mt.Length == 0)
                    {
                        continue;
                    }

                    foreach (TransformInfo ti in transforms)
                    {
                        mt = ti.Regex.Replace(mt, ti.ReplaceText);
                    }

                    try {
                        mt = StringEscaping.UnEscape(ri.EscapeMode, mt);
                    } catch (FormatException fex) {
                        monitor.ReportWarning("Error unescaping string '" + mt + "': " + fex.Message);
                        continue;
                    }

                    if (mt.Trim().Length == 0)
                    {
                        continue;
                    }

                    //get the plural string if it's a plural form and apply transforms
                    string pt = ri.PluralGroupIndex != -1 ? match.Groups[ri.PluralGroupIndex].Value : null;
                    if (pt != null)
                    {
                        foreach (TransformInfo ti in transforms)
                        {
                            pt = ti.Regex.Replace(pt, ti.ReplaceText);
                        }
                    }

                    //add to the catalog
                    CatalogEntry entry = catalog.AddItem(mt, pt);
                    lineNumber += GetLineCount(text, oldIndex, match.Index);
                    oldIndex    = match.Index;
                    entry.AddReference(fileNamePrefix + lineNumber);
                }
            }
        }
		public bool CanScan (TranslationProject project, Catalog catalog, string fileName, string mimeType)
		{
			if (extensions.Count == 0 && mimeTypes.Count == 0)
				return true;
			string ext = Path.GetExtension (fileName);
			if (ext.Length > 0) ext = ext.Substring (1); // remove initial dot
			bool r = extensions.Contains (ext) || mimeTypes.Contains (mimeType);
			return r;
		}
		public virtual void UpdateCatalog (TranslationProject project, Catalog catalog, IProgressMonitor monitor, string fileName)
		{
			string text = File.ReadAllText (fileName);
			string relativeFileName = MonoDevelop.Core.FileService.AbsoluteToRelativePath (project.BaseDirectory, fileName);
			string fileNamePrefix   = relativeFileName + ":";
			if (String.IsNullOrEmpty (text))
				return;
			
			// Get a list of all excluded regions
			List<Match> excludeMatches = new List<Match> ();
			foreach (Regex regex in excluded) {
				foreach (Match m in regex.Matches (text))
					excludeMatches.Add (m);
			}
			
			// Sort the list by match index
			excludeMatches.Sort (delegate (Match a, Match b) {
				return a.Index.CompareTo (b.Index);
			});
			
			// Remove from the list all regions which start in an excluded region
			int pos=0;
			for (int n=0; n<excludeMatches.Count; n++) {
				Match m = excludeMatches [n];
				if (m.Index < pos) {
					excludeMatches.RemoveAt (n);
					n--;
				} else {
					pos = m.Index + m.Length;
				}
			}
			
			foreach (RegexInfo ri in regexes) {
				int lineNumber = 0;
				int oldIndex  = 0;
				foreach (Match match in ri.Regex.Matches (text)) {
					// Ignore matches inside excluded regions
					bool ignore = false;
					foreach (Match em in excludeMatches) {
						if (match.Index >= em.Index && match.Index < em.Index + em.Length) {
							ignore = true;
							LoggingService.LogDebug ("Excluded Gettext string '{0}' in file '{1}'", match.Groups[ri.ValueGroupIndex].Value, fileName);
							break;
						}
					}
					if (ignore)
						continue;
					
					string mt = match.Groups[ri.ValueGroupIndex].Value;
					if (mt.Length == 0)
						continue;
					
					foreach (TransformInfo ti in transforms)
						mt = ti.Regex.Replace (mt, ti.ReplaceText);
					
					try {
						mt = StringEscaping.UnEscape (ri.EscapeMode, mt);
					} catch (FormatException fex) {
						monitor.ReportWarning ("Error unescaping string '" + mt + "': " + fex.Message);
						continue;
					}
					
					if (mt.Trim().Length == 0)
						continue;
					
					//get the plural string if it's a plural form and apply transforms
					string pt = ri.PluralGroupIndex != -1 ? match.Groups[ri.PluralGroupIndex].Value : null;
					if (pt != null)
						foreach (TransformInfo ti in transforms)
							pt = ti.Regex.Replace (pt, ti.ReplaceText);
					
					//add to the catalog
					CatalogEntry entry = catalog.AddItem (mt, pt);
					lineNumber += GetLineCount (text, oldIndex, match.Index);
					oldIndex = match.Index;
					entry.AddReference (fileNamePrefix + lineNumber);
				}
			}
		}
Exemplo n.º 13
0
		public POEditorWidget (TranslationProject project)
		{
			this.project = project;
			this.Build ();
			this.headersEditor = new CatalogHeadersWidget ();
			this.notebookPages.AppendPage (headersEditor, new Gtk.Label ());
			
			updateThread = new BackgroundWorker ();
			updateThread.WorkerSupportsCancellation = true;
			updateThread.DoWork += FilterWorker;
			
			updateTaskThread = new BackgroundWorker ();
			updateTaskThread.WorkerSupportsCancellation = true;
			updateTaskThread.DoWork += TaskUpdateWorker;
			
			AddButton (GettextCatalog.GetString ("Translation")).Active = true;
			AddButton (GettextCatalog.GetString ("Headers")).Active = false;
			
			// entries tree view 
			store = new ListStore (typeof(string), typeof(bool), typeof(string), typeof(string), typeof(CatalogEntry), typeof(Gdk.Color), typeof(int), typeof(Gdk.Color));
			this.treeviewEntries.Model = store;
			
			treeviewEntries.AppendColumn (String.Empty, new CellRendererIcon (), "stock_id", Columns.Stock, "cell-background-gdk", Columns.RowColor);
			
			CellRendererToggle cellRendFuzzy = new CellRendererToggle ();
			cellRendFuzzy.Toggled += new ToggledHandler (FuzzyToggled);
			cellRendFuzzy.Activatable = true;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Fuzzy"), cellRendFuzzy, "active", Columns.Fuzzy, "cell-background-gdk", Columns.RowColor);
			
			CellRendererText original = new CellRendererText ();
			original.Ellipsize = Pango.EllipsizeMode.End;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Original string"), original, "text", Columns.String, "cell-background-gdk", Columns.RowColor, "foreground-gdk", Columns.ForeColor);
			
			CellRendererText translation = new CellRendererText ();
			translation.Ellipsize = Pango.EllipsizeMode.End;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Translated string"), translation, "text", Columns.Translation, "cell-background-gdk", Columns.RowColor, "foreground-gdk", Columns.ForeColor);
			treeviewEntries.Selection.Changed += new EventHandler (OnEntrySelected);
			
			treeviewEntries.GetColumn (0).SortIndicator = true;
			treeviewEntries.GetColumn (0).SortColumnId = (int)Columns.TypeSortIndicator;
			
			treeviewEntries.GetColumn (1).SortIndicator = true;
			treeviewEntries.GetColumn (1).SortColumnId = (int)Columns.Fuzzy;
			
			treeviewEntries.GetColumn (2).SortIndicator = true;
			treeviewEntries.GetColumn (2).SortColumnId = (int)Columns.String;
			treeviewEntries.GetColumn (2).Resizable = true;
			treeviewEntries.GetColumn (2).Expand = true;
			
			treeviewEntries.GetColumn (3).SortIndicator = true;
			treeviewEntries.GetColumn (3).SortColumnId = (int)Columns.Translation;
			treeviewEntries.GetColumn (3).Resizable = true;
			treeviewEntries.GetColumn (3).Expand = true;
			// found in tree view
			foundInStore = new ListStore (typeof(string), typeof(string), typeof(string), typeof(Pixbuf));
			this.treeviewFoundIn.Model = foundInStore;
			
			TreeViewColumn fileColumn = new TreeViewColumn ();
			var pixbufRenderer = new CellRendererPixbuf ();
			fileColumn.PackStart (pixbufRenderer, false);
			fileColumn.SetAttributes (pixbufRenderer, "pixbuf", FoundInColumns.Pixbuf);
			
			CellRendererText textRenderer = new CellRendererText ();
			fileColumn.PackStart (textRenderer, true);
			fileColumn.SetAttributes (textRenderer, "text", FoundInColumns.File);
			treeviewFoundIn.AppendColumn (fileColumn);
			
			treeviewFoundIn.AppendColumn ("", new CellRendererText (), "text", FoundInColumns.Line);
			treeviewFoundIn.HeadersVisible = false;
			treeviewFoundIn.GetColumn (1).FixedWidth = 100;
			
			treeviewFoundIn.RowActivated += delegate(object sender, RowActivatedArgs e) {
				Gtk.TreeIter iter;
				foundInStore.GetIter (out iter, e.Path);
				string line = foundInStore.GetValue (iter, (int)FoundInColumns.Line) as string;
				string file = foundInStore.GetValue (iter, (int)FoundInColumns.FullFileName) as string;
				int lineNr = 1;
				try {
					lineNr = 1 + int.Parse (line);
				} catch {
				}
				IdeApp.Workbench.OpenDocument (file, lineNr, 1, true);
			};
			this.notebookTranslated.RemovePage (0);
			this.searchEntryFilter.Entry.Text = "";
			searchEntryFilter.Entry.Changed += delegate {
				UpdateFromCatalog ();
			};
			
			this.togglebuttonFuzzy.Active = PropertyService.Get ("Gettext.ShowFuzzy", true);
			this.togglebuttonFuzzy.TooltipText = GettextCatalog.GetString ("Show fuzzy translations");
			this.togglebuttonFuzzy.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowFuzzy", this.togglebuttonFuzzy.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonMissing.Active = PropertyService.Get ("Gettext.ShowMissing", true);
			this.togglebuttonMissing.TooltipText = GettextCatalog.GetString ("Show missing translations");
			this.togglebuttonMissing.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowMissing", this.togglebuttonMissing.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonOk.Active = PropertyService.Get ("Gettext.ShowTranslated", true);
			this.togglebuttonOk.TooltipText = GettextCatalog.GetString ("Show valid translations");
			this.togglebuttonOk.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowTranslated", this.togglebuttonOk.Active);
				UpdateFromCatalog ();
			};
			
			this.textviewComments.Buffer.Changed += delegate {
				if (this.isUpdating)
					return;
				if (this.currentEntry != null) {
					string[] lines = StringEscaping.FromGettextFormat (textviewComments.Buffer.Text).Split (new string[] { System.Environment.NewLine }, System.StringSplitOptions.None);
					for (int i = 0; i < lines.Length; i++) {
						if (!lines[i].StartsWith ("#"))
							lines[i] = "# " + lines[i];
					}
					this.currentEntry.Comment = string.Join (System.Environment.NewLine, lines);
				}
				UpdateProgressBar ();
			};
			this.treeviewEntries.PopupMenu += delegate {
				ShowPopup ();
			};
			
			this.treeviewEntries.ButtonReleaseEvent += delegate(object sender, Gtk.ButtonReleaseEventArgs e) {
				if (e.Event.Button == 3)
					ShowPopup ();
			};
			
			searchEntryFilter.Ready = true;
			searchEntryFilter.Visible = true;
			searchEntryFilter.ForceFilterButtonVisible = true;
			searchEntryFilter.RequestMenu += delegate {
				searchEntryFilter.Menu = CreateOptionsMenu ();
			};
		
//			this.buttonOptions.Label = GettextCatalog.GetString ("Options");
			//			this.buttonOptions.StockImage = Gtk.Stock.Properties;
			//			this.buttonOptions.MenuCreator = ;
			widgets.Add (this);
			UpdateTasks ();
			//			this.vpaned2.AcceptPosition += delegate {
			//				PropertyService.Set ("Gettext.SplitPosition", vpaned2.Position / (double)Allocation.Height);
			//				inMove = false;
			//			};
			//			this.vpaned2.CancelPosition += delegate {
			//				inMove = false;
			//			};
			//			this.vpaned2.MoveHandle += delegate {
			//				inMove = true;
			//			};
			//			this.ResizeChecked += delegate {
			//				if (inMove)
			//					return;
			//				int newPosition = (int)(Allocation.Height * PropertyService.Get ("Gettext.SplitPosition", 0.3d));
			//				if (vpaned2.Position != newPosition)
			//					vpaned2.Position = newPosition;
			//			};
			checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;
			options.ShowLineNumberMargin = false;
			options.ShowFoldMargin = false;
			options.ShowIconMargin = false;
			options.ShowInvalidLines = false;
			options.ShowSpaces = options.ShowTabs = options.ShowEolMarkers = false;
			options.ColorScheme = PropertyService.Get ("ColorScheme", "Default");
			options.FontName = PropertyService.Get<string> ("FontName");
			
			this.scrolledwindowOriginal.Child = this.texteditorOriginal;
			this.scrolledwindowPlural.Child = this.texteditorPlural;
			this.texteditorOriginal.Show ();
			this.texteditorPlural.Show ();
			texteditorOriginal.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			texteditorPlural.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			this.texteditorOriginal.Options = options;
			this.texteditorPlural.Options = options;
			this.texteditorOriginal.Document.ReadOnly = true;
			this.texteditorPlural.Document.ReadOnly = true;
		}
Exemplo n.º 14
0
 internal Translation(TranslationProject prj, string isoCode)
 {
     this.parentProject = prj;
     this.isoCode       = isoCode;
 }
Exemplo n.º 15
0
        public TranslationProjectOptionsDialog(TranslationProject project)
        {
            this.project = project;
            this.Build();

            entryPackageName.Text        = project.PackageName;
            entryRelPath.Text            = project.RelPath;
            radiobuttonRelPath.Active    = project.OutputType == TranslationOutputType.RelativeToOutput;
            radiobuttonSystemPath.Active = project.OutputType == TranslationOutputType.SystemPath;

            entryPackageName.Changed        += new EventHandler(UpdateInitString);
            entryRelPath.Changed            += new EventHandler(UpdateInitString);
            radiobuttonRelPath.Activated    += new EventHandler(UpdateInitString);
            radiobuttonSystemPath.Activated += new EventHandler(UpdateInitString);

            UpdateInitString(this, EventArgs.Empty);
            this.buttonOk.Clicked += delegate {
                project.PackageName = entryPackageName.Text;
                project.RelPath     = entryRelPath.Text;
                if (radiobuttonRelPath.Active)
                {
                    project.OutputType = TranslationOutputType.RelativeToOutput;
                }
                else
                {
                    project.OutputType = TranslationOutputType.SystemPath;
                }
                this.Destroy();
            };
            this.buttonCancel.Clicked += delegate {
                this.Destroy();
            };

            store = new TreeStore(typeof(string), typeof(bool), typeof(string), typeof(SolutionItem), typeof(bool));
            treeviewProjectList.Model          = store;
            treeviewProjectList.HeadersVisible = false;

            TreeViewColumn col = new TreeViewColumn();

            CellRendererToggle cellRendererToggle = new CellRendererToggle();

            cellRendererToggle.Toggled    += new ToggledHandler(ActiveToggled);
            cellRendererToggle.Activatable = true;
            col.PackStart(cellRendererToggle, false);
            col.AddAttribute(cellRendererToggle, "active", 1);
            col.AddAttribute(cellRendererToggle, "visible", 4);

            CellRendererPixbuf crp = new CellRendererPixbuf();

            col.PackStart(crp, false);
            col.AddAttribute(crp, "stock_id", 0);

            CellRendererText crt = new CellRendererText();

            col.PackStart(crt, true);
            col.AddAttribute(crt, "text", 2);

            treeviewProjectList.AppendColumn(col);

            FillTree(TreeIter.Zero, project.ParentSolution.RootFolder);
        }
		// Expecting iso-8859-1 encoding
		public CharsetInfoFinder (TranslationProject project, string poFile)
			: base (poFile, Encoding.GetEncoding ("iso-8859-1"))
		{
			this.project = project;
			charset = "iso-8859-1";
		}
Exemplo n.º 17
0
 internal TranslationCollection(TranslationProject project)
 {
     this.project = project;
 }