示例#1
0
        // Copied from bin/src/LocaleStrings/Program.cs. Should remove this functionality there eventually.
        private static void StoreTranslatedContextHelp(XmlElement xelRoot,
                                                       Dictionary <string, POString> dictTrans)
        {
            XmlElement xelGroup = xelRoot.OwnerDocument.CreateElement("group");

            xelGroup.SetAttribute("id", "LocalizedContextHelp");
            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)
                {
                    string sId = FindContextHelpId(rgs[i]);
                    if (!String.IsNullOrEmpty(sId))
                    {
                        XmlElement xelString = xelRoot.OwnerDocument.CreateElement("string");
                        xelString.SetAttribute("id", sId);
                        xelString.SetAttribute("txt", sValue);
                        xelGroup.AppendChild(xelString);
                        break;
                    }
                }
            }
            xelRoot.AppendChild(xelGroup);
        }
 /// <summary>
 /// This nicely recursive method replaces the English txt attribute values with the
 /// corresponding translated values if they exist.
 /// </summary>
 /// <param name="xel"></param>
 /// <param name="dictTrans"></param>
 // Copied from bin/src/LocaleStrings/Program.cs. Should remove this functionality there eventually.
 private static void TranslateStringsElements(XmlElement xel,
                                              Dictionary <string, POString> dictTrans)
 {
     if (xel.Name == "string")
     {
         POString pos      = null;
         string   sEnglish = xel.GetAttribute("txt");
         if (dictTrans.TryGetValue(sEnglish, out pos))
         {
             string sTranslation = pos.MsgStrAsString();
             xel.SetAttribute("txt", sTranslation);
             xel.SetAttribute("English", sEnglish);
         }
     }
     foreach (XmlNode xn in xel.ChildNodes)
     {
         if (xn is XmlElement)
         {
             TranslateStringsElements(xn as XmlElement, dictTrans);
         }
     }
 }
示例#3
0
        // 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);
        }