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 diff
     1.1 --- a/IBBoard.csproj	Tue Jan 31 20:46:10 2012 +0000
     1.2 +++ b/IBBoard.csproj	Sun Jun 24 15:48:25 2012 +0100
     1.3 @@ -201,12 +201,6 @@
     1.4      <None Include="app.config" />
     1.5      <None Include="COPYING.GPL" />
     1.6      <None Include="COPYING.LGPL" />
     1.7 -    <None Include="schemas\translation.xsd">
     1.8 -      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     1.9 -      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
    1.10 -      <SubType>
    1.11 -      </SubType>
    1.12 -    </None>
    1.13    </ItemGroup>
    1.14    <ProjectExtensions>
    1.15      <MonoDevelop>
    1.16 @@ -219,4 +213,9 @@
    1.17      </MonoDevelop>
    1.18      <VisualStudio />
    1.19    </ProjectExtensions>
    1.20 +  <ItemGroup>
    1.21 +    <EmbeddedResource Include="schemas\translation.xsd">
    1.22 +      <Gettext-ScanForTranslations>false</Gettext-ScanForTranslations>
    1.23 +    </EmbeddedResource>
    1.24 +  </ItemGroup>
    1.25  </Project>
    1.26 \ No newline at end of file
     2.1 --- a/Lang/Translation.cs	Tue Jan 31 20:46:10 2012 +0000
     2.2 +++ b/Lang/Translation.cs	Sun Jun 24 15:48:25 2012 +0100
     2.3 @@ -77,7 +77,7 @@
     2.4  				throw new TranslationLoadException("Translation path not found (" + dir.FullName + ")");
     2.5  			}
     2.6  						
     2.7 -			TranslationXmlLoader loader = new TranslationXmlLoader(Path.Combine(appPath, "schemas/translation.xsd"));
     2.8 +			TranslationXmlLoader loader = new TranslationXmlLoader();
     2.9  			
    2.10  			foreach (FileInfo file in dir.GetFiles("*.translation"))
    2.11  			{
     3.1 --- a/Lang/TranslationXmlLoader.cs	Tue Jan 31 20:46:10 2012 +0000
     3.2 +++ b/Lang/TranslationXmlLoader.cs	Sun Jun 24 15:48:25 2012 +0100
     3.3 @@ -1,7 +1,6 @@
     3.4  // This file (TranslationXmlLoader.cs) is a part of the IBBoard project and is copyright 2010 IBBoard
     3.5  // 
     3.6  // 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.
     3.7 -
     3.8  using System;
     3.9  using System.IO;
    3.10  using System.Xml;
    3.11 @@ -9,6 +8,7 @@
    3.12  using System.Collections.Generic;
    3.13  using IBBoard.IO;
    3.14  using IBBoard.Xml;
    3.15 +using System.Reflection;
    3.16  
    3.17  namespace IBBoard.Lang
    3.18  {
    3.19 @@ -18,23 +18,20 @@
    3.20  	public class TranslationXmlLoader
    3.21  	{
    3.22  		private XmlReaderSettings settings;
    3.23 -		private string schemaLocation;
    3.24  		private TranslationXmlExtractor extractor;
    3.25  		
    3.26 -		public TranslationXmlLoader(string schemaLocation)
    3.27 +		public TranslationXmlLoader()
    3.28  		{
    3.29 -			this.schemaLocation = schemaLocation;
    3.30  			extractor = new TranslationXmlExtractor();
    3.31  		}
    3.32  		
    3.33 -		
    3.34  		public AbstractTranslationSet LoadTranslations(string path)
    3.35  		{
    3.36  			FileInfo file = new FileInfo(path);
    3.37  			
    3.38  			if (!file.Exists)
    3.39  			{
    3.40 -				throw new TranslationLoadException("Translation file "+file.FullName+" did not exist");
    3.41 +				throw new TranslationLoadException("Translation file " + file.FullName + " did not exist");
    3.42  			}				
    3.43  				
    3.44  			XmlDocument doc = LoadTranslationDocument(file);
    3.45 @@ -88,9 +85,9 @@
    3.46  					settings = new XmlReaderSettings();
    3.47  					settings.ValidationType = ValidationType.Schema;
    3.48  					settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings;
    3.49 -					settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
    3.50 +					settings.ValidationEventHandler += new ValidationEventHandler(ValidationEventMethod);
    3.51  					XmlSchemaSet cache = new XmlSchemaSet();
    3.52 -					cache.Add("http://ibboard.co.uk/translation", schemaLocation);
    3.53 +					cache.Add("http://ibboard.co.uk/translation", new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("IBBoard.schemas.translation.xsd")));
    3.54  					settings.Schemas.Add(cache);
    3.55  				}
    3.56  				catch (DirectoryNotFoundException ex)