Exemplo n.º 1
0
 public XmlLocalize(string _path, string _locs)
 {
     BaseFile    = _locs;
     Path        = _path;
     Translation = Load_Locs(_locs);
     if (Translation == null)
     {
         Translation = new GLocalizeCountry();
     }
 }
Exemplo n.º 2
0
        public GLocalizeCountry Localize_Base(string _file)
        {
            int    num    = 0;
            int    num2   = 0;
            string idEnum = "";
            string loc    = "";
            string text   = "";
            int    id     = 0;

            GLocalizeItem.Tipos tipo             = GLocalizeItem.Tipos.Desconocido;
            GLocalizeCountry    gLocalizeCountry = new GLocalizeCountry();

            try
            {
                XmlTextReader xmlTextReader = new XmlTextReader(Path + _file);
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Text && num == 1)
                    {
                        text = xmlTextReader.Value.ToString();
                        GLocalizeItem gLocalizeItem = new GLocalizeItem();
                        gLocalizeItem.Translated  = true;
                        gLocalizeItem.Tipo        = tipo;
                        gLocalizeItem.Loc         = loc;
                        gLocalizeItem.Id          = id;
                        gLocalizeItem.IdEnum      = idEnum;
                        gLocalizeItem.Original    = text;
                        gLocalizeItem.Translation = text;
                        gLocalizeCountry.CopyItem(gLocalizeItem);
                        num = 0;
                    }
                    if (xmlTextReader.NodeType == XmlNodeType.Element)
                    {
                        if (xmlTextReader.Name.ToLower() == "localize")
                        {
                            num2 = 1;
                            if (xmlTextReader.HasAttributes)
                            {
                                xmlTextReader.MoveToFirstAttribute();
                                for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                                {
                                    xmlTextReader.MoveToAttribute(i);
                                    if (xmlTextReader.Name.ToLower() == "iso")
                                    {
                                        gLocalizeCountry.BaseLoc = (gLocalizeCountry.Loc = xmlTextReader.Value.ToString());
                                    }
                                }
                            }
                        }
                        if (xmlTextReader.Name.ToLower() == "text" && num2 == 1)
                        {
                            num = 1;
                            if (xmlTextReader.HasAttributes)
                            {
                                xmlTextReader.MoveToFirstAttribute();
                                for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                                {
                                    xmlTextReader.MoveToAttribute(i);
                                    if (xmlTextReader.Name.ToLower() == "iso")
                                    {
                                        loc = xmlTextReader.Value.ToString();
                                    }
                                    else if (xmlTextReader.Name.ToLower() == "id")
                                    {
                                        id = Convert.ToInt32(xmlTextReader.Value.ToString());
                                    }
                                    else if (xmlTextReader.Name.ToLower() == "enum")
                                    {
                                        idEnum = xmlTextReader.Value.ToString();
                                    }
                                    else if (xmlTextReader.Name.ToLower() == "type")
                                    {
                                        string text2 = xmlTextReader.Value.ToString();
                                        switch (text2.ToLower())
                                        {
                                        case "imagen":
                                            tipo = GLocalizeItem.Tipos.Imagen;
                                            break;

                                        case "link":
                                            tipo = GLocalizeItem.Tipos.Link;
                                            break;

                                        case "texto":
                                            tipo = GLocalizeItem.Tipos.Texto;
                                            break;

                                        case "video":
                                            tipo = GLocalizeItem.Tipos.Video;
                                            break;

                                        case "datos":
                                            tipo = GLocalizeItem.Tipos.Datos;
                                            break;

                                        case "audio":
                                            tipo = GLocalizeItem.Tipos.Audio;
                                            break;

                                        default:
                                            tipo = GLocalizeItem.Tipos.Desconocido;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        xmlTextReader.MoveToElement();
                                    }
                                }
                            }
                        }
                        if (xmlTextReader.NodeType == XmlNodeType.EndElement && xmlTextReader.Name.ToLower() == "localize")
                        {
                            num2 = 0;
                        }
                    }
                }
                xmlTextReader.Close();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(null);
            }
            return(gLocalizeCountry);
        }
Exemplo n.º 3
0
        public bool Localize_Country(ref GLocalizeCountry _l, string _file)
        {
            int    num  = 0;
            int    num2 = 0;
            string text = "";
            string id   = "0";

            try
            {
                XmlTextReader xmlTextReader = new XmlTextReader(Path + _file);
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Text && num == 1)
                    {
                        text = xmlTextReader.Value.ToString();
                        GLocalizeItem gLocalizeItem = new GLocalizeItem();
                        _l.EditTranslation(id, text);
                        num = 0;
                    }
                    if (xmlTextReader.NodeType == XmlNodeType.Element)
                    {
                        if (xmlTextReader.Name.ToLower() == "localize")
                        {
                            num2 = 1;
                            if (xmlTextReader.HasAttributes)
                            {
                                xmlTextReader.MoveToFirstAttribute();
                                for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                                {
                                    xmlTextReader.MoveToAttribute(i);
                                    if (xmlTextReader.Name.ToLower() == "iso")
                                    {
                                        _l.Loc = xmlTextReader.Value.ToString();
                                    }
                                }
                            }
                        }
                        if (xmlTextReader.Name.ToLower() == "text" && num2 == 1)
                        {
                            num = 1;
                            if (xmlTextReader.HasAttributes)
                            {
                                xmlTextReader.MoveToFirstAttribute();
                                for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                                {
                                    xmlTextReader.MoveToAttribute(i);
                                    if (xmlTextReader.Name.ToLower() == "id")
                                    {
                                        id = xmlTextReader.Value.ToString();
                                    }
                                    else
                                    {
                                        xmlTextReader.MoveToElement();
                                    }
                                }
                            }
                        }
                        if (xmlTextReader.NodeType == XmlNodeType.EndElement && xmlTextReader.Name.ToLower() == "localize")
                        {
                            num2 = 0;
                        }
                    }
                }
                xmlTextReader.Close();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        private GLocalizeCountry Load_Locs(string _file)
        {
            int              num              = 0;
            string           text             = "";
            string           text2            = "";
            GLocalizeCountry gLocalizeCountry = null;

            try
            {
                XmlTextReader xmlTextReader = new XmlTextReader(Path + _file);
                while (xmlTextReader.Read())
                {
                    if (xmlTextReader.NodeType == XmlNodeType.Element)
                    {
                        if (xmlTextReader.Name.ToLower() == "countries")
                        {
                            num = 1;
                            if (xmlTextReader.HasAttributes)
                            {
                                xmlTextReader.MoveToFirstAttribute();
                                for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                                {
                                    xmlTextReader.MoveToAttribute(i);
                                    if (xmlTextReader.Name.ToLower() == "iso")
                                    {
                                        text2 = xmlTextReader.Value.ToString();
                                    }
                                    else if (xmlTextReader.Name.ToLower() == "file")
                                    {
                                        text = xmlTextReader.Value.ToString();
                                    }
                                }
                            }
                            gLocalizeCountry          = Localize_Base(text);
                            gLocalizeCountry.BaseFile = text;
                            gLocalizeCountry.BaseLoc  = text2;
                        }
                        if (xmlTextReader.Name.ToLower() == "country" && num == 1 && xmlTextReader.HasAttributes)
                        {
                            xmlTextReader.MoveToFirstAttribute();
                            for (int i = 0; i < xmlTextReader.AttributeCount; i++)
                            {
                                xmlTextReader.MoveToAttribute(i);
                                if (xmlTextReader.Name.ToLower() == "iso")
                                {
                                    text2 = xmlTextReader.Value.ToString();
                                }
                                else if (xmlTextReader.Name.ToLower() == "file")
                                {
                                    text = xmlTextReader.Value.ToString();
                                }
                                else
                                {
                                    xmlTextReader.MoveToElement();
                                }
                            }
                            Array.Resize(ref gLocalizeCountry.Locs, gLocalizeCountry.Locs.Length + 1);
                            gLocalizeCountry.Locs[gLocalizeCountry.Locs.Length - 1] = text2;
                            Array.Resize(ref gLocalizeCountry.LocsFile, gLocalizeCountry.LocsFile.Length + 1);
                            gLocalizeCountry.LocsFile[gLocalizeCountry.LocsFile.Length - 1] = text;
                        }
                    }
                    if (xmlTextReader.NodeType == XmlNodeType.EndElement && xmlTextReader.Name.ToLower() == "countries")
                    {
                        num = 0;
                    }
                }
                xmlTextReader.Close();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(null);
            }
            return(gLocalizeCountry);
        }