changeset 83:13f0ffb012cb

Re warfoundry:#272 : Program errors on exit if language file fails to load. * Make ID of translation required * Add method to check if language exists no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 15 May 2010 14:41:41 +0000
parents 5182df00c558
children 0fc997256e65
files Lang/Translation.cs schemas/translation.xsd
diffstat 2 files changed, 12 insertions(+), 14 deletions(-) [+]
line diff
     1.1 --- a/Lang/Translation.cs	Sun Apr 18 19:01:36 2010 +0000
     1.2 +++ b/Lang/Translation.cs	Sat May 15 14:41:41 2010 +0000
     1.3 @@ -48,7 +48,7 @@
     1.4  		public static void InitialiseTranslations(string appPath, string language)
     1.5  		{
     1.6  			InitialiseTranslations(appPath);
     1.7 -			LoadTranslationForLanguage(language);
     1.8 +			LoadTranslation(language);
     1.9  		}
    1.10  		
    1.11  		/// <summary>
    1.12 @@ -128,18 +128,11 @@
    1.13  		/// The new local language to load
    1.14  		/// </param>
    1.15  		public static void LoadTranslation(string translationLanguage)
    1.16 -		{
    1.17 -			if (translationLanguage == "" || translationLanguage == null)
    1.18 -			{
    1.19 -				throw new ArgumentException("Translation language cannot be null or empty");
    1.20 +		{
    1.21 +			if (HasLanguage(translationLanguage))
    1.22 +			{
    1.23 +				SetCurrentTranslations(GetTranslationSet(translationLanguage));
    1.24  			}
    1.25 -
    1.26 -			LoadTranslationForLanguage(translationLanguage);
    1.27 -		}
    1.28 -		
    1.29 -		private static void LoadTranslationForLanguage(string translationLanguage)
    1.30 -		{			
    1.31 -			SetCurrentTranslations(GetTranslationSet(translationLanguage));
    1.32  		}
    1.33  
    1.34  		/// <summary>
    1.35 @@ -318,6 +311,11 @@
    1.36  			}
    1.37  			
    1.38  			return translations;
    1.39 -		}
    1.40 +		}
    1.41 +
    1.42 +		public static bool HasLanguage(string languageCode)
    1.43 +		{
    1.44 +			return langToTranslationMap.ContainsKey(languageCode);
    1.45 +		}
    1.46  	}
    1.47  }
     2.1 --- a/schemas/translation.xsd	Sun Apr 18 19:01:36 2010 +0000
     2.2 +++ b/schemas/translation.xsd	Sat May 15 14:41:41 2010 +0000
     2.3 @@ -3,7 +3,7 @@
     2.4  <xs:complexType name="translationtype">
     2.5      <xs:simpleContent>
     2.6        <xs:extension base="xs:string">
     2.7 -        <xs:attribute name="id" type="xs:ID" />
     2.8 +        <xs:attribute name="id" type="xs:ID" use="required" />
     2.9        </xs:extension>
    2.10      </xs:simpleContent>
    2.11  </xs:complexType>