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 diff
     1.1 --- a/Lang/AbstractTranslationSet.cs	Wed Apr 07 19:34:38 2010 +0000
     1.2 +++ b/Lang/AbstractTranslationSet.cs	Wed Apr 07 19:55:05 2010 +0000
     1.3 @@ -15,23 +15,11 @@
     1.4  	{
     1.5  		private TranslationLanguage language;
     1.6  		protected Dictionary<string, string> translations;
     1.7 -		private TranslationLanguage parentLang;
     1.8  		
     1.9 -		public AbstractTranslationSet(string languageCode) : this(languageCode, "")
    1.10 -		{
    1.11 -			//Do nothing extra
    1.12 -		}
    1.13 -		
    1.14 -		public AbstractTranslationSet(string languageCode, string parentLanguageCode)
    1.15 +		public AbstractTranslationSet(string languageCode)
    1.16  		{
    1.17  			language = new TranslationLanguage(languageCode);
    1.18  			translations = new Dictionary<string, string>();
    1.19 -			
    1.20 -			if (parentLanguageCode != null && !parentLanguageCode.Trim().Equals(""))
    1.21 -			{
    1.22 -				ParentLanguage = new TranslationLanguage(parentLanguageCode);
    1.23 -			}
    1.24 -			
    1.25  		}
    1.26  		
    1.27  		
    1.28 @@ -55,7 +43,7 @@
    1.29  			{
    1.30  				string translation = DictionaryUtils.GetValue(translations, key);
    1.31  				
    1.32 -				if (parentLang != null && translation == null)
    1.33 +				if (translation == null)
    1.34  				{
    1.35  					translation = GetParentTranslation(key);
    1.36  				}
    1.37 @@ -94,8 +82,18 @@
    1.38  		
    1.39  		public TranslationLanguage ParentLanguage
    1.40  		{
    1.41 -			get { return parentLang; }
    1.42 -			protected set { parentLang = value; }
    1.43 +			get
    1.44 +			{
    1.45 +				TranslationLanguage parentLang = null;
    1.46 +				AbstractTranslationSet parentTranslations = GetParentTranslations();
    1.47 +				
    1.48 +				if (parentTranslations != null)
    1.49 +				{
    1.50 +					parentLang = parentTranslations.Language;
    1.51 +				}
    1.52 +				
    1.53 +				return parentLang;
    1.54 +			}
    1.55  		}
    1.56  		
    1.57  		public override bool Equals(object obj)
     2.1 --- a/Lang/ModifiableTranslationSet.cs	Wed Apr 07 19:34:38 2010 +0000
     2.2 +++ b/Lang/ModifiableTranslationSet.cs	Wed Apr 07 19:55:05 2010 +0000
     2.3 @@ -14,12 +14,7 @@
     2.4  	{		
     2.5  		private AbstractTranslationSet parentTranslationSet;
     2.6  		
     2.7 -		public ModifiableTranslationSet(string languageCode) : this(languageCode, "")
     2.8 -		{
     2.9 -			//Do nothing extra
    2.10 -		}
    2.11 -		
    2.12 -		public ModifiableTranslationSet(string languageCode, string parentLanguageCode) : base(languageCode, parentLanguageCode)
    2.13 +		public ModifiableTranslationSet(string languageCode) : base(languageCode)
    2.14  		{
    2.15  			//Do nothing extra
    2.16  		}
    2.17 @@ -31,7 +26,6 @@
    2.18  
    2.19  		public void SetParentTranslations(ModifiableTranslationSet parentTranslations)
    2.20  		{
    2.21 -			ParentLanguage = parentTranslations.Language;
    2.22  			parentTranslationSet = parentTranslations;
    2.23  		}
    2.24