Mercurial > repos > IBBoard
comparison Lang/TranslationXmlExtractor.cs @ 80:a23c07137fa4
Re #32: Add staged loading of translations
* Move from passing entire document to XmlTranslationSet to just passing XmlNodeList of translation nodes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 10 Apr 2010 19:05:26 +0000 |
parents | a70d89de1435 |
children |
comparison
equal
deleted
inserted
replaced
79:a70d89de1435 | 80:a23c07137fa4 |
---|---|
8 | 8 |
9 namespace IBBoard.Lang | 9 namespace IBBoard.Lang |
10 { | 10 { |
11 public class TranslationXmlExtractor | 11 public class TranslationXmlExtractor |
12 { | 12 { |
13 public Dictionary<string, string> ExtractTranslationsFromDocument(XmlDocument doc) | 13 public XmlNodeList GetTranslationNodes(XmlDocument doc) |
14 { | 14 { |
15 try | 15 try |
16 { | 16 { |
17 XmlNodeList translationNodes = doc.GetElementsByTagName("translation"); | 17 return doc.GetElementsByTagName("translation"); |
18 Dictionary<string, string> translationStrings = new Dictionary<string, string>(); | |
19 | |
20 foreach (XmlNode node in translationNodes) | |
21 { | |
22 string id = node.Attributes["id"].Value; | |
23 string text = node.InnerText; | |
24 translationStrings.Add(id, text); | |
25 } | |
26 | |
27 return translationStrings; | |
28 } | 18 } |
29 catch(Exception ex) | 19 catch(Exception ex) |
30 { | 20 { |
31 throw new TranslationLoadException("Error while parsing " + GetLanguageOfDocument(doc)+" translation: "+ex.Message, ex); | 21 throw new TranslationLoadException("Error while parsing " + GetLanguageOfDocument(doc)+" translation: "+ex.Message, ex); |
32 } | 22 } |