changeset 7:f4da31cb09d9

* Add translation DTD to utils project * Alter Translation class to resolve error when initialising with an empty local language (should default to no local language, not exception) no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 02 Jan 2009 20:12:06 +0000
parents f269d8bcc152
children d6ce8764e92b
files IBBoard.mdp Lang/Translation.cs dtds/translation.dtd
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.mdp	Sat Dec 27 20:28:04 2008 +0000
+++ b/IBBoard.mdp	Fri Jan 02 20:12:06 2009 +0000
@@ -43,6 +43,8 @@
     <File name="Logging/LogNotifier.cs" subtype="Code" buildaction="Compile" />
     <File name="Collections" subtype="Directory" buildaction="Compile" />
     <File name="Collections/SimpleSet.cs" subtype="Code" buildaction="Compile" />
+    <File name="dtds" subtype="Directory" buildaction="Compile" />
+    <File name="dtds/translation.dtd" subtype="Code" buildaction="Nothing" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
--- a/Lang/Translation.cs	Sat Dec 27 20:28:04 2008 +0000
+++ b/Lang/Translation.cs	Fri Jan 02 20:12:06 2009 +0000
@@ -136,16 +136,21 @@
 		/// <param name="translationLang">
 		/// The new local language to load
 		/// </param>
-		public static void LoadTranslation(string translationLang)
-		{
-			checkInitialisation();
-			
-			if (translationLang == "" || translationLang == null)
+		public static void LoadTranslation(string translationLanguage)
+		{			
+			if (translationLanguage == "" || translationLanguage == null)
 			{
 				throw new ArgumentException("Translation language cannot be empty or null");
 			}
 
-			if (translationLang != DEFAULT_LANGUAGE)
+			LoadTranslationForLang(translationLanguage);
+		}
+		
+		private static void LoadTranslationForLanguage(string translationLanguage)
+		{
+			checkInitialisation();
+			
+			if (translationLanguage != DEFAULT_LANGUAGE && translationLanguage != "" && translationLanguage != null)
 			{
 				FileInfo file = GetTranslationFile(translationLang);
 				XmlDocument doc = LoadTranslationDocument(file);
@@ -156,7 +161,7 @@
 				translationsLocal.Clear();				
 			}
 			
-			lang = translationLang;
+			lang = translationLang;
 		}
 
 		/// <summary>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dtds/translation.dtd	Fri Jan 02 20:12:06 2009 +0000
@@ -0,0 +1,4 @@
+<!ELEMENT translations (translation*)>
+<!ELEMENT translation (#PCDATA)> <!-- it's a damned ugly hack, but C# won't take "#CDATA" so use #PCDATA and always treat it as CDATA -->
+<!ATTLIST translation id ID #REQUIRED>
+<!ATTLIST translations lang CDATA #REQUIRED>
\ No newline at end of file