// Copied from bin/src/LocaleStrings/Program.cs. Should remove this functionality there eventually. private static void StoreTranslatedLiterals(XmlElement xelRoot, Dictionary <string, POString> dictTrans) { XmlElement xelGroup = xelRoot.OwnerDocument.CreateElement("group"); xelGroup.SetAttribute("id", "LocalizedLiterals"); Dictionary <string, POString> .Enumerator en = dictTrans.GetEnumerator(); while (en.MoveNext()) { POString pos = en.Current.Value; string sValue = pos.MsgStrAsString(); if (String.IsNullOrEmpty(sValue)) { continue; } List <string> rgs = pos.AutoComments; if (rgs == null) { continue; } for (int i = 0; i < rgs.Count; ++i) { if (rgs[i] != null && rgs[i].StartsWith("/") && rgs[i].EndsWith("/lit")) { XmlElement xelString = xelRoot.OwnerDocument.CreateElement("string"); xelString.SetAttribute("id", pos.MsgIdAsString()); xelString.SetAttribute("txt", sValue); xelGroup.AppendChild(xelString); break; } } } xelRoot.AppendChild(xelGroup); }
private static Dictionary <string, POString> LoadPOFile(string sMsgFile, out POString posHeader) { using (StreamReader srIn = new StreamReader(sMsgFile, Encoding.UTF8)) { Dictionary <string, POString> dictTrans = new Dictionary <string, POString>(); posHeader = POString.ReadFromFile(srIn); POString pos = POString.ReadFromFile(srIn); while (pos != null) { if (!pos.HasEmptyMsgStr && (pos.Flags == null || !pos.Flags.Contains("fuzzy"))) { dictTrans.Add(pos.MsgIdAsString(), pos); } pos = POString.ReadFromFile(srIn); } srIn.Close(); return(dictTrans); } }
// Copied from bin/src/LocaleStrings/Program.cs. Should remove this functionality there eventually. private static void StoreTranslatedAttributes(XmlElement xelRoot, Dictionary <string, POString> dictTrans) { XmlElement xelGroup = xelRoot.OwnerDocument.CreateElement("group"); xelGroup.SetAttribute("id", "LocalizedAttributes"); Dictionary <string, POString> .Enumerator en = dictTrans.GetEnumerator(); while (en.MoveNext()) { POString pos = en.Current.Value; string sValue = pos.MsgStrAsString(); if (String.IsNullOrEmpty(sValue)) { continue; } List <string> rgs = pos.AutoComments; if (rgs == null) { continue; } for (int i = 0; i < rgs.Count; ++i) { if (rgs[i] != null && // handle bug in creating original POT file due to case sensitive search. (rgs[i].StartsWith("/") || rgs[i].StartsWith("file:///")) && IsFromXmlAttribute(rgs[i])) { XmlElement xelString = xelRoot.OwnerDocument.CreateElement("string"); xelString.SetAttribute("id", pos.MsgIdAsString()); xelString.SetAttribute("txt", sValue); xelGroup.AppendChild(xelString); break; } } } xelRoot.AppendChild(xelGroup); }