Ejemplo n.º 1
0
    private void ReadLocale(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                //util.AddMessage("Start locale entry element: " + reader.Name);

                if (reader.Name.Equals("id"))
                {
                    string id = reader.ReadString();
                    if (!int.TryParse(id, out m_languageId))
                    {
                        util.AddError("Couldn't parse language id from '" + id + "'");
                    }
                }
                if (reader.Name.Equals("code"))
                {
                    m_languageCode = reader.ReadString();
                }
                if (reader.Name.Equals("name"))
                {
                    m_languageName = reader.ReadString();
                }
                if (reader.Name.Equals("texts"))
                {
                    ReadTexts(reader);
                }
            }
            else if (reader.Name.Equals("locale"))
            {
                // Done reading locale
                //util.AddMessage("End of locale");
                break;
            }
            else
            {
                util.AddWarning("Unexpected element closed: " + reader.Name);
            }
        }

        if (m_languageId == -1)
        {
            util.AddError("Couldn't parse language id");
        }
        if (m_languageCode == null)
        {
            util.AddError("Couldn't parse language code");
        }
        if (m_languageName == null)
        {
            util.AddError("Couldn't parse language name");
        }
        if (m_texts.Count == 0)
        {
            util.AddWarning("No texts parsed or found");
        }
    }
Ejemplo n.º 2
0
    private void ReadTexts(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                if (reader.Name.Equals("text"))
                {
                    //util.AddMessage("Text entry found");
                    ReadText(reader);
                }
                else
                {
                    util.AddWarning("Unexpected element started: " + reader.Name);
                }
            }
            else if (reader.Name.Equals("texts"))
            {
                // Done reading texts
                //util.AddMessage("End of texts");
                break;
            }
            else
            {
                util.AddWarning("Unexpected element closed: " + reader.Name);
            }
        }
    }
Ejemplo n.º 3
0
    private void ReadText(XmlTextReader reader)
    {
        TransfluentUtility util = TransfluentUtility.GetInstance();

        string textId     = null;
        string textString = null;

        while (reader.Read())
        {
            if (reader.IsStartElement())
            {
                //util.AddMessage("Start text entry element: " + reader.Name);

                if (reader.Name.Equals("textId"))
                {
                    textId = reader.ReadString();
                }
                else if (reader.Name.Equals("textString"))
                {
                    textString = reader.ReadString();
                }
                else
                {
                    util.AddWarning("Unexpected element started: " + reader.Name);
                }
            }
            else if (reader.Name.Equals("text"))
            {
                // Done reading this element
                //util.AddMessage("End of text entry");
                break;
            }
            else
            {
                util.AddWarning("Unexpected element closed: " + reader.Name);
            }
        }

        if (textId != null && textString != null)
        {
            //util.AddMessage("XML: Found text entry: Id='" + textId + "', String='" + textString + "'");
            m_texts.Add(textId, textString);
        }
        else
        {
            util.AddError("XML: Error reading text entry: Id='" + textId + "', String='" + textString + "'");
        }
    }