예제 #1
0
        public string Translator(string input, TranslateKind kind)
        {
            switch (kind)
            {
            case TranslateKind.Naver:
                return(NaverTranslator(input));

            case TranslateKind.Google:
                return(GoogleTranslator(input));

            case TranslateKind.InfoSeek:
                break;

            default:
                break;
            }
            return(string.Empty);
        }
예제 #2
0
 public string Translator(string input, TranslateKind kind)
 {
     switch (kind)
     {
         case TranslateKind.Naver:
             return NaverTranslator(input);
         case TranslateKind.Google:
             return GoogleTranslator(input);
         case TranslateKind.InfoSeek:
             break;
         default:
             break;
     }
     return string.Empty;
 }
예제 #3
0
 private IEnumerable<XElement> GetTranslationList(TranslationType type, TranslateKind sitetype = TranslateKind.Google)
 {
     if (TranslationType.PartTranslate == type)
     {
         if (JPTRs != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.JPTRs = XDocument.Load(Path.Combine(MainFolder, "XMLs", "JPTRs.xml"));
                 GrandcypherClient.Current.Updater.JPTRsUpdate = false;
             }
             return JPTRs.Descendants("JPTR");
         }
         return null;
     }
     else if (type == TranslationType.ScenarioDetail)
     {
         string siteKind = "Google";
         if (sitetype == TranslateKind.Naver) siteKind = "Naver";
         if (File.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml")))
             Scenarios = XDocument.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml"));
         if (Scenarios != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.Scenarios = XDocument.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml"));
                 GrandcypherClient.Current.Updater.JPTRsUpdate = false;
             }
             return Scenarios.Descendants("Scenario");
         }
         return null;
     }
     else if (type == TranslationType.FirstSkillName || type == TranslationType.LastSkillName || type == TranslationType.WeaponList || type == TranslationType.FirstSkillDetail || type == TranslationType.LastSkillDetail || TranslationType.WeaponType == type || TranslationType.Element == type)
     {
         if (WeaponLists != null)
         {
             if (GrandcypherClient.Current.Updater.WeaponListUpdate)
             {
                 this.WeaponLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "WeaponList.xml"));
                 GrandcypherClient.Current.Updater.WeaponListUpdate = false;
             }
             return WeaponLists.Descendants("Weapon");
         }
         return null;
     }
     else if (TranslationType.SkillDetails == type)
     {
         if (WeaponSkills != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.WeaponSkills = XDocument.Load(Path.Combine(MainFolder, "XMLs", "SkillList.xml"));
                 GrandcypherClient.Current.Updater.SkillListUpdate = false;
             }
             return WeaponSkills.Descendants("Skill");
         }
         return null;
     }
     else if (TranslationType.TenTreasure == type)
     {
         if (TenLists != null)
         {
             if (GrandcypherClient.Current.Updater.TenListUpdate)
             {
                 this.TenLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "TenList.xml"));
                 GrandcypherClient.Current.Updater.TenListUpdate = false;
             }
             return TenLists.Descendants("Treasure");
         }
         return null;
     }
     else if (TranslationType.BulletMake == type)
     {
         if (BulletLists != null)
         {
             if (GrandcypherClient.Current.Updater.BulletListUpdate)
             {
                 this.BulletLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "BulletList.xml"));
                 GrandcypherClient.Current.Updater.BulletListUpdate = false;
             }
             return BulletLists.Descendants("Bullet");
         }
         return null;
     }
     else if (TranslationType.ItemIdx == type)
     {
         if (ItemLists != null)
         {
             if (GrandcypherClient.Current.Updater.ItemListUpdate)
             {
                 this.ItemLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "ItemList.xml"));
                 GrandcypherClient.Current.Updater.ItemListUpdate = false;
             }
             return ItemLists.Descendants("Item");
         }
         return null;
     }
     else return null;
 }
예제 #4
0
        public void WriteFile(List<Scenario> context, TranslateKind type)
        {
            XmlDocument NewXmlDoc = new XmlDocument();
            NewXmlDoc.AppendChild(NewXmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            XmlNode Source = NewXmlDoc.CreateElement("", "Scenarios", "");
            NewXmlDoc.AppendChild(Source);

            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs")))
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs"));
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios")))
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios"));
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "Google")))
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Google"));
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "Naver")))
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Naver"));
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "raw")))
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Raw"));

            string sub_folder = string.Empty;
            if (type == TranslateKind.Google)
                sub_folder = "Google";
            else if (type == TranslateKind.Naver)
                sub_folder = "Naver";
            else if (type == TranslateKind.Raw)
                sub_folder = "Raw";

            NewXmlDoc.Save(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));

            XmlDocument XmlDoc = new XmlDocument();
            XmlDoc.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));
            foreach (var item in context)
            {
                XmlNode FristNode = XmlDoc.DocumentElement;

                XmlElement root = XmlDoc.CreateElement("Scenario");
                root.SetAttribute("id", item.index.ToString());
                root.SetAttribute("JPName", item.Name);
                root.SetAttribute("TrName", item.TrName);
                root.SetAttribute("JPDtail", item.context);
                root.SetAttribute("TrDtail", item.TrContext);

                FristNode.AppendChild(root);
            }

            XmlDoc.Save(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));
        }
예제 #5
0
        public string GetTranslation(TranslationType type, string JPString, TranslateKind sitekind, int MasterId = -1)
        {
            try
            {
                IEnumerable<XElement> TranslationList = GetTranslationList(type, sitekind);

                string JPChildElement = "JPstring";
                string TRChildElement = "TRstring";
                string IDElement = "ID";

                if (MasterId < 0)
                {
                    if (type == TranslationType.ScenarioDetail)
                    {
                        JPChildElement = "JPDtail";
                        TRChildElement = "TrDtail";

                        IEnumerable<XElement> OldFoundTranslation = TranslationList.Where(b => b.Attribute(JPChildElement).Value.Equals(JPString));

                        foreach (XElement el in OldFoundTranslation)
                        {
                            return el.Attribute(TRChildElement).Value;
                        }
                    }
                    else if (type == TranslationType.FirstSkillName || type == TranslationType.LastSkillName)
                    {
                        JPChildElement = "JpName";
                        TRChildElement = "KrName";

                        IEnumerable<XElement> OldFoundTranslation = TranslationList.Where(b => b.Attribute(JPChildElement).Value.Equals(JPString));

                        foreach (XElement el in OldFoundTranslation)
                        {
                            return el.Attribute(TRChildElement).Value;
                        }
                    }
                    else
                    {
                        IEnumerable<XElement> OldFoundTranslation = TranslationList.Where(b => b.Element(JPChildElement).Value.Equals(JPString));//string 비교검색
                        foreach (XElement el in OldFoundTranslation)
                        {
                            return el.Element(TRChildElement).Value;
                        }
                    }

            #if DEBUG
                    Debug.WriteLine(string.Format("Can't find Translation: {0,-20} {1}", JPString, MasterId));
            #endif
                }
                else
                {
                    switch (type)
                    {
                        case TranslationType.WeaponList:
                            TRChildElement = "Name";
                            break;
                        case TranslationType.FirstSkillName:
                            TRChildElement = "Skill1";
                            break;
                        case TranslationType.FirstSkillDetail:
                            TRChildElement = "Skill1Detail";
                            break;
                        case TranslationType.LastSkillName:
                            TRChildElement = "Skill2";
                            break;
                        case TranslationType.LastSkillDetail:
                            TRChildElement = "Skill2Detail";
                            break;
                        case TranslationType.Element:
                            TRChildElement = "Element";
                            break;
                        case TranslationType.WeaponType:
                            TRChildElement = "Kind";
                            break;
                    }

                    IEnumerable<XElement> FoundTranslation = TranslationList.Where(b => b.Element(IDElement).Value.Equals(MasterId.ToString()));//아이템 ID검색

                    foreach (XElement el in FoundTranslation)
                    {
                        if (MasterId >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == MasterId)
                            return el.Element(TRChildElement).Value;
                    }
                }

            }
            catch
            {
                return "";
            }

            return JPString;
        }
예제 #6
0
        public void WriteFile(List <Scenario> context, TranslateKind type)
        {
            XmlDocument NewXmlDoc = new XmlDocument();

            NewXmlDoc.AppendChild(NewXmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes"));
            XmlNode Source = NewXmlDoc.CreateElement("", "Scenarios", "");

            NewXmlDoc.AppendChild(Source);

            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs")))
            {
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs"));
            }
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios")))
            {
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios"));
            }
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "Google")))
            {
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Google"));
            }
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "Naver")))
            {
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Naver"));
            }
            if (!Directory.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", "raw")))
            {
                Directory.CreateDirectory(Path.Combine(MainFolder, "XMLs", "Scenarios", "Raw"));
            }

            string sub_folder = string.Empty;

            if (type == TranslateKind.Google)
            {
                sub_folder = "Google";
            }
            else if (type == TranslateKind.Naver)
            {
                sub_folder = "Naver";
            }
            else if (type == TranslateKind.Raw)
            {
                sub_folder = "Raw";
            }

            NewXmlDoc.Save(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));

            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));
            foreach (var item in context)
            {
                XmlNode FristNode = XmlDoc.DocumentElement;

                XmlElement root = XmlDoc.CreateElement("Scenario");
                root.SetAttribute("id", item.index.ToString());
                root.SetAttribute("JPName", item.Name);
                root.SetAttribute("TrName", item.TrName);
                root.SetAttribute("JPDtail", item.context);
                root.SetAttribute("TrDtail", item.TrContext);

                FristNode.AppendChild(root);
            }

            XmlDoc.Save(Path.Combine(MainFolder, "XMLs", "Scenarios", sub_folder, context[0].PathName + ".xml"));
        }
예제 #7
0
        public string GetTranslation(TranslationType type, string JPString, TranslateKind sitekind, int MasterId = -1)
        {
            try
            {
                IEnumerable <XElement> TranslationList = GetTranslationList(type, sitekind);

                string JPChildElement = "JPstring";
                string TRChildElement = "TRstring";
                string IDElement      = "ID";



                if (MasterId < 0)
                {
                    if (type == TranslationType.ScenarioDetail)
                    {
                        JPChildElement = "JPDtail";
                        TRChildElement = "TrDtail";

                        IEnumerable <XElement> OldFoundTranslation = TranslationList.Where(b => b.Attribute(JPChildElement).Value.Equals(JPString));

                        foreach (XElement el in OldFoundTranslation)
                        {
                            return(el.Attribute(TRChildElement).Value);
                        }
                    }
                    else if (type == TranslationType.FirstSkillName || type == TranslationType.LastSkillName)
                    {
                        JPChildElement = "JpName";
                        TRChildElement = "KrName";

                        IEnumerable <XElement> OldFoundTranslation = TranslationList.Where(b => b.Attribute(JPChildElement).Value.Equals(JPString));

                        foreach (XElement el in OldFoundTranslation)
                        {
                            return(el.Attribute(TRChildElement).Value);
                        }
                    }
                    else
                    {
                        IEnumerable <XElement> OldFoundTranslation = TranslationList.Where(b => b.Element(JPChildElement).Value.Equals(JPString));                       //string 비교검색
                        foreach (XElement el in OldFoundTranslation)
                        {
                            return(el.Element(TRChildElement).Value);
                        }
                    }

#if DEBUG
                    Debug.WriteLine(string.Format("Can't find Translation: {0,-20} {1}", JPString, MasterId));
#endif
                }
                else
                {
                    switch (type)
                    {
                    case TranslationType.WeaponList:
                        TRChildElement = "Name";
                        break;

                    case TranslationType.FirstSkillName:
                        TRChildElement = "Skill1";
                        break;

                    case TranslationType.FirstSkillDetail:
                        TRChildElement = "Skill1Detail";
                        break;

                    case TranslationType.LastSkillName:
                        TRChildElement = "Skill2";
                        break;

                    case TranslationType.LastSkillDetail:
                        TRChildElement = "Skill2Detail";
                        break;

                    case TranslationType.Element:
                        TRChildElement = "Element";
                        break;

                    case TranslationType.WeaponType:
                        TRChildElement = "Kind";
                        break;
                    }

                    IEnumerable <XElement> FoundTranslation = TranslationList.Where(b => b.Element(IDElement).Value.Equals(MasterId.ToString()));                   //아이템 ID검색

                    foreach (XElement el in FoundTranslation)
                    {
                        if (MasterId >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == MasterId)
                        {
                            return(el.Element(TRChildElement).Value);
                        }
                    }
                }
            }
            catch
            {
                return("");
            }

            return(JPString);
        }
예제 #8
0
 private IEnumerable <XElement> GetTranslationList(TranslationType type, TranslateKind sitetype = TranslateKind.Google)
 {
     if (TranslationType.PartTranslate == type)
     {
         if (JPTRs != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.JPTRs = XDocument.Load(Path.Combine(MainFolder, "XMLs", "JPTRs.xml"));
                 GrandcypherClient.Current.Updater.JPTRsUpdate = false;
             }
             return(JPTRs.Descendants("JPTR"));
         }
         return(null);
     }
     else if (type == TranslationType.ScenarioDetail)
     {
         string siteKind = "Google";
         if (sitetype == TranslateKind.Naver)
         {
             siteKind = "Naver";
         }
         if (File.Exists(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml")))
         {
             Scenarios = XDocument.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml"));
         }
         if (Scenarios != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.Scenarios = XDocument.Load(Path.Combine(MainFolder, "XMLs", "Scenarios", siteKind, GrandcypherClient.Current.ScenarioHooker.PathName + ".xml"));
                 GrandcypherClient.Current.Updater.JPTRsUpdate = false;
             }
             return(Scenarios.Descendants("Scenario"));
         }
         return(null);
     }
     else if (type == TranslationType.FirstSkillName || type == TranslationType.LastSkillName || type == TranslationType.WeaponList || type == TranslationType.FirstSkillDetail || type == TranslationType.LastSkillDetail || TranslationType.WeaponType == type || TranslationType.Element == type)
     {
         if (WeaponLists != null)
         {
             if (GrandcypherClient.Current.Updater.WeaponListUpdate)
             {
                 this.WeaponLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "WeaponList.xml"));
                 GrandcypherClient.Current.Updater.WeaponListUpdate = false;
             }
             return(WeaponLists.Descendants("Weapon"));
         }
         return(null);
     }
     else if (TranslationType.SkillDetails == type)
     {
         if (WeaponSkills != null)
         {
             if (GrandcypherClient.Current.Updater.JPTRsUpdate)
             {
                 this.WeaponSkills = XDocument.Load(Path.Combine(MainFolder, "XMLs", "SkillList.xml"));
                 GrandcypherClient.Current.Updater.SkillListUpdate = false;
             }
             return(WeaponSkills.Descendants("Skill"));
         }
         return(null);
     }
     else if (TranslationType.TenTreasure == type)
     {
         if (TenLists != null)
         {
             if (GrandcypherClient.Current.Updater.TenListUpdate)
             {
                 this.TenLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "TenList.xml"));
                 GrandcypherClient.Current.Updater.TenListUpdate = false;
             }
             return(TenLists.Descendants("Treasure"));
         }
         return(null);
     }
     else if (TranslationType.BulletMake == type)
     {
         if (BulletLists != null)
         {
             if (GrandcypherClient.Current.Updater.BulletListUpdate)
             {
                 this.BulletLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "BulletList.xml"));
                 GrandcypherClient.Current.Updater.BulletListUpdate = false;
             }
             return(BulletLists.Descendants("Bullet"));
         }
         return(null);
     }
     else if (TranslationType.ItemIdx == type)
     {
         if (ItemLists != null)
         {
             if (GrandcypherClient.Current.Updater.ItemListUpdate)
             {
                 this.ItemLists = XDocument.Load(Path.Combine(MainFolder, "XMLs", "ItemList.xml"));
                 GrandcypherClient.Current.Updater.ItemListUpdate = false;
             }
             return(ItemLists.Descendants("Item"));
         }
         return(null);
     }
     else
     {
         return(null);
     }
 }