Mercurial > repos > IBBoard
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 wrap: on
line diff
--- a/Lang/Translation.cs Sun Apr 18 19:01:36 2010 +0000 +++ b/Lang/Translation.cs Sat May 15 14:41:41 2010 +0000 @@ -48,7 +48,7 @@ public static void InitialiseTranslations(string appPath, string language) { InitialiseTranslations(appPath); - LoadTranslationForLanguage(language); + LoadTranslation(language); } /// <summary> @@ -128,18 +128,11 @@ /// The new local language to load /// </param> public static void LoadTranslation(string translationLanguage) - { - if (translationLanguage == "" || translationLanguage == null) - { - throw new ArgumentException("Translation language cannot be null or empty"); + { + if (HasLanguage(translationLanguage)) + { + SetCurrentTranslations(GetTranslationSet(translationLanguage)); } - - LoadTranslationForLanguage(translationLanguage); - } - - private static void LoadTranslationForLanguage(string translationLanguage) - { - SetCurrentTranslations(GetTranslationSet(translationLanguage)); } /// <summary> @@ -318,6 +311,11 @@ } return translations; - } + } + + public static bool HasLanguage(string languageCode) + { + return langToTranslationMap.ContainsKey(languageCode); + } } }
--- a/schemas/translation.xsd Sun Apr 18 19:01:36 2010 +0000 +++ b/schemas/translation.xsd Sat May 15 14:41:41 2010 +0000 @@ -3,7 +3,7 @@ <xs:complexType name="translationtype"> <xs:simpleContent> <xs:extension base="xs:string"> - <xs:attribute name="id" type="xs:ID" /> + <xs:attribute name="id" type="xs:ID" use="required" /> </xs:extension> </xs:simpleContent> </xs:complexType>