comparison Lang/TranslationXmlLoader.cs @ 79:a70d89de1435

Re #32: Add staged loading of translations * Add "extends" attribute to schema so that translation files can define what they extend * Add "get parent language" method to extractor * Move loader to using XML translation sets
author IBBoard <dev@ibboard.co.uk>
date Fri, 09 Apr 2010 19:48:51 +0000
parents da339d10c5fe
children a23c07137fa4
comparison
equal deleted inserted replaced
78:da339d10c5fe 79:a70d89de1435
36 { 36 {
37 throw new TranslationLoadException("Translation file "+file.FullName+" did not exist"); 37 throw new TranslationLoadException("Translation file "+file.FullName+" did not exist");
38 } 38 }
39 39
40 XmlDocument doc = LoadTranslationDocument(file); 40 XmlDocument doc = LoadTranslationDocument(file);
41 ModifiableTranslationSet translations = new ModifiableTranslationSet(extractor.GetLanguageOfDocument(doc)); 41 XmlTranslationSet translations = new XmlTranslationSet(extractor.GetLanguageOfDocument(doc));
42 LoadTranslationsFromDocument(doc, translations); 42 translations.SetParentLanguage(extractor.GetParentLanguageOfDocument(doc));
43 translations.SetSourceXml(doc);
43 return translations; 44 return translations;
44 } 45 }
45 46
46 private XmlDocument LoadTranslationDocument(FileInfo file) 47 private XmlDocument LoadTranslationDocument(FileInfo file)
47 { 48 {
111 112
112 private void ValidationEventMethod(object sender, ValidationEventArgs e) 113 private void ValidationEventMethod(object sender, ValidationEventArgs e)
113 { 114 {
114 throw new TranslationLoadException("Problem validating schema for translation: " + e.Exception.Message, e.Exception); 115 throw new TranslationLoadException("Problem validating schema for translation: " + e.Exception.Message, e.Exception);
115 } 116 }
116
117 private void LoadTranslationsFromDocument(XmlDocument doc, ModifiableTranslationSet translations)
118 {
119 Dictionary<string, string> translationStrings = extractor.ExtractTranslationsFromDocument(doc);
120
121 foreach (KeyValuePair<string, string> translation in translationStrings)
122 {
123 translations.SetTranslation(translation.Key, translation.Value);
124 }
125 }
126 } 117 }
127 } 118 }