changeset 113:e32b5ccda410

* Update Translations to use built-in schema
author IBBoard <dev@ibboard.co.uk>
date Sun, 24 Jun 2012 15:48:25 +0100
parents 3262c0ad2d3d
children 7ca4acc659bb de0ed24eb961
files IBBoard.csproj Lang/Translation.cs Lang/TranslationXmlLoader.cs
diffstat 3 files changed, 11 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.csproj	Tue Jan 31 20:46:10 2012 +0000
+++ b/IBBoard.csproj	Sun Jun 24 15:48:25 2012 +0100
@@ -201,12 +201,6 @@
     <None Include="app.config" />
     <None Include="COPYING.GPL" />
     <None Include="COPYING.LGPL" />
-    <None Include="schemas\translation.xsd">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
-      <SubType>
-      </SubType>
-    </None>
   </ItemGroup>
   <ProjectExtensions>
     <MonoDevelop>
@@ -219,4 +213,9 @@
     </MonoDevelop>
     <VisualStudio />
   </ProjectExtensions>
+  <ItemGroup>
+    <EmbeddedResource Include="schemas\translation.xsd">
+      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
+    </EmbeddedResource>
+  </ItemGroup>
 </Project>
\ No newline at end of file
--- a/Lang/Translation.cs	Tue Jan 31 20:46:10 2012 +0000
+++ b/Lang/Translation.cs	Sun Jun 24 15:48:25 2012 +0100
@@ -77,7 +77,7 @@
 				throw new TranslationLoadException("Translation path not found (" + dir.FullName + ")");
 			}
 						
-			TranslationXmlLoader loader = new TranslationXmlLoader(Path.Combine(appPath, "schemas/translation.xsd"));
+			TranslationXmlLoader loader = new TranslationXmlLoader();
 			
 			foreach (FileInfo file in dir.GetFiles("*.translation"))
 			{
--- a/Lang/TranslationXmlLoader.cs	Tue Jan 31 20:46:10 2012 +0000
+++ b/Lang/TranslationXmlLoader.cs	Sun Jun 24 15:48:25 2012 +0100
@@ -1,7 +1,6 @@
 // This file (TranslationXmlLoader.cs) is a part of the IBBoard project and is copyright 2010 IBBoard
 // 
 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
-
 using System;
 using System.IO;
 using System.Xml;
@@ -9,6 +8,7 @@
 using System.Collections.Generic;
 using IBBoard.IO;
 using IBBoard.Xml;
+using System.Reflection;
 
 namespace IBBoard.Lang
 {
@@ -18,23 +18,20 @@
 	public class TranslationXmlLoader
 	{
 		private XmlReaderSettings settings;
-		private string schemaLocation;
 		private TranslationXmlExtractor extractor;
 		
-		public TranslationXmlLoader(string schemaLocation)
+		public TranslationXmlLoader()
 		{
-			this.schemaLocation = schemaLocation;
 			extractor = new TranslationXmlExtractor();
 		}
 		
-		
 		public AbstractTranslationSet LoadTranslations(string path)
 		{
 			FileInfo file = new FileInfo(path);
 			
 			if (!file.Exists)
 			{
-				throw new TranslationLoadException("Translation file "+file.FullName+" did not exist");
+				throw new TranslationLoadException("Translation file " + file.FullName + " did not exist");
 			}				
 				
 			XmlDocument doc = LoadTranslationDocument(file);
@@ -88,9 +85,9 @@
 					settings = new XmlReaderSettings();
 					settings.ValidationType = ValidationType.Schema;
 					settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;
-					settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
+					settings.ValidationEventHandler += new ValidationEventHandler(ValidationEventMethod);
 					XmlSchemaSet cache = new XmlSchemaSet();
-					cache.Add("http://ibboard.co.uk/translation", schemaLocation);
+					cache.Add("http://ibboard.co.uk/translation", new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("IBBoard.schemas.translation.xsd")));
 					settings.Schemas.Add(cache);
 				}
 				catch (DirectoryNotFoundException ex)