示例#1
0
        // throws XmlException, NotValidException
        private void GetTranslations(ISong song, string translations, bool imp)
        {
            if (translations == "")
                return;
            string[] trs = translations.Split(',');
            XmlNode curt;
            for (int i = 0; i < trs.Length; i++)
            {
                if ((curt = this.doc.GetElementById(trs[i])) != null)
                {
                    XmlNodeList transchildren = curt.ChildNodes;

                    int lang = Util.getLanguageInt(curt.Attributes["lang"].Value);
                    string id = curt.Attributes["id"].Value;
                    bool uf = curt.Attributes["unform"].Value.Equals("yes");
                    string text;
                    string title;
                    if ((transchildren[0].Name == "Title") &&
                        (transchildren[1].Name == "Text"))
                    {
                        title = transchildren[0].InnerText;
                        text = transchildren[1].InnerText;
                    }
                    else
                    {
                        throw new NotValidException();
                    }
                    string newid = HighestTrID;
                    song.AddTranslation(
                        new Translation(title, text, lang, uf, "t" + Util.toFour(highestTrID), imp || (newid != id)));
                }
                else
                {
                    Util.MBoxError("Die Übersetzung \"" + trs[i] + "\" konnte nicht gefunden werden!");
                }
            }
        }