changeset 17:a9c60e6c4b5b

Re #47: Add translatable GTK# widgets * Simplify ControlTranslator and avoid infinite loops that cause unlogged crashes.
author IBBoard <dev@ibboard.co.uk>
date Wed, 01 Dec 2010 20:57:36 +0000
parents c9aeaeaa3ea2
children 9b3c4fd0b191
files Translatable/ControlTranslator.cs
diffstat 1 files changed, 14 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Translatable/ControlTranslator.cs	Tue Nov 23 21:01:28 2010 +0000
+++ b/Translatable/ControlTranslator.cs	Wed Dec 01 20:57:36 2010 +0000
@@ -16,32 +16,28 @@
 	{
 		public static void TranslateWidget(Widget toTranslate)
 		{
+			TranslateWidget(toTranslate, true);
+		}
+
+		public static void TranslateWidget(Widget toTranslate, bool cascade)
+		{
 			if (toTranslate is ITranslatable)
 			{
 				Translation.Translate((ITranslatable)toTranslate);
 			}
-		}
-		
-		public static void TranslateWidget(Widget toTranslate, bool cascade)
-		{
-			TranslateWidget(toTranslate);
+			
+			if (cascade && toTranslate is Container)
+			{
+				CascadeTranslations((Container)toTranslate, cascade);
+			}
 		}
 
-		public static void TranslateWidget(Container toTranslate)
-		{
-			TranslateWidget(toTranslate, true);
-		}
-		
-		public static void TranslateWidget(Container toTranslate, bool cascade)
+		private static void CascadeTranslations(Container container, bool cascade)
 		{
-			TranslateWidget(toTranslate);
-			
-			if (cascade)
+			foreach (Widget childWidget in container.AllChildren)
 			{
-				foreach (Widget childWidget in toTranslate.AllChildren)
-				{
-					TranslateWidget(childWidget, cascade);
-				}
+				System.Console.WriteLine(childWidget);
+				TranslateWidget(childWidget, cascade);
 			}
 		}