changeset 76:f45d28dc1d6a

Re #35: Add multi-level cascading of translations * Restructure translations so that implementations define how parent translations are set TODO: Stop looping definition of parent (en-GB inherits from en inherits from en-GB, or more indirect)
author IBBoard <dev@ibboard.co.uk>
date Wed, 07 Apr 2010 19:55:05 +0000
parents b1ae6fce2e3f
children eb47e17ec824
files Lang/AbstractTranslationSet.cs Lang/ModifiableTranslationSet.cs
diffstat 2 files changed, 15 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Lang/AbstractTranslationSet.cs	Wed Apr 07 19:34:38 2010 +0000
+++ b/Lang/AbstractTranslationSet.cs	Wed Apr 07 19:55:05 2010 +0000
@@ -15,23 +15,11 @@
 	{
 		private TranslationLanguage language;
 		protected Dictionary<string, string> translations;
-		private TranslationLanguage parentLang;
 		
-		public AbstractTranslationSet(string languageCode) : this(languageCode, "")
-		{
-			//Do nothing extra
-		}
-		
-		public AbstractTranslationSet(string languageCode, string parentLanguageCode)
+		public AbstractTranslationSet(string languageCode)
 		{
 			language = new TranslationLanguage(languageCode);
 			translations = new Dictionary<string, string>();
-			
-			if (parentLanguageCode != null && !parentLanguageCode.Trim().Equals(""))
-			{
-				ParentLanguage = new TranslationLanguage(parentLanguageCode);
-			}
-			
 		}
 		
 		
@@ -55,7 +43,7 @@
 			{
 				string translation = DictionaryUtils.GetValue(translations, key);
 				
-				if (parentLang != null && translation == null)
+				if (translation == null)
 				{
 					translation = GetParentTranslation(key);
 				}
@@ -94,8 +82,18 @@
 		
 		public TranslationLanguage ParentLanguage
 		{
-			get { return parentLang; }
-			protected set { parentLang = value; }
+			get
+			{
+				TranslationLanguage parentLang = null;
+				AbstractTranslationSet parentTranslations = GetParentTranslations();
+				
+				if (parentTranslations != null)
+				{
+					parentLang = parentTranslations.Language;
+				}
+				
+				return parentLang;
+			}
 		}
 		
 		public override bool Equals(object obj)
--- a/Lang/ModifiableTranslationSet.cs	Wed Apr 07 19:34:38 2010 +0000
+++ b/Lang/ModifiableTranslationSet.cs	Wed Apr 07 19:55:05 2010 +0000
@@ -14,12 +14,7 @@
 	{		
 		private AbstractTranslationSet parentTranslationSet;
 		
-		public ModifiableTranslationSet(string languageCode) : this(languageCode, "")
-		{
-			//Do nothing extra
-		}
-		
-		public ModifiableTranslationSet(string languageCode, string parentLanguageCode) : base(languageCode, parentLanguageCode)
+		public ModifiableTranslationSet(string languageCode) : base(languageCode)
 		{
 			//Do nothing extra
 		}
@@ -31,7 +26,6 @@
 
 		public void SetParentTranslations(ModifiableTranslationSet parentTranslations)
 		{
-			ParentLanguage = parentTranslations.Language;
 			parentTranslationSet = parentTranslations;
 		}