Ejemplo n.º 1
0
        protected override Translation LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             TranslationTable.GetColumnNames("[t]") +
                             (this.Depth > 0 ? "," + TranslationTypeTable.GetColumnNames("[t_tt]") : string.Empty) +
                             " FROM [core].[Translation] AS [t] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationType] AS [t_tt] ON [t].[TranslationTypeID] = [t_tt].[TranslationTypeID] ";
                }
                sqlCmdText += "WHERE [t].[TranslationID] = @TranslationID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@TranslationID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("t", "loadinternal", "notfound"), "Translation could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                TranslationTable     tTable    = new TranslationTable(query);
                TranslationTypeTable t_ttTable = (this.Depth > 0) ? new TranslationTypeTable(query) : null;


                TranslationType t_ttObject = (this.Depth > 0) ? t_ttTable.CreateInstance() : null;
                Translation     tObject    = tTable.CreateInstance(t_ttObject);
                sqlReader.Close();

                return(tObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("t", "loadinternal", "exception"), "Translation could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Translation", "Exception while loading Translation object from database. See inner exception for details.", ex);
            }
        }
        public static TranslationProviderType TypeToProviderType(TranslationType type)
        {
            switch (type)
            {
            case TranslationType.App:
                return(TranslationProviderType.App);

            case TranslationType.Equipment:
                return(TranslationProviderType.Equipment);

            case TranslationType.Ships:
                return(TranslationProviderType.Ships);

            case TranslationType.ShipTypes:
                return(TranslationProviderType.ShipTypes);

            case TranslationType.Operations:
            case TranslationType.OperationMaps:
            case TranslationType.OperationSortie:
                return(TranslationProviderType.Operations);

            case TranslationType.Quests:
            case TranslationType.QuestDetail:
            case TranslationType.QuestTitle:
                return(TranslationProviderType.Quests);

            case TranslationType.Expeditions:
            case TranslationType.ExpeditionTitle:
            case TranslationType.ExpeditionDetail:
                return(TranslationProviderType.Expeditions);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <XElement> GetTranslationList(TranslationType Type)
        {
            switch (Type)
            {
            case TranslationType.Ships:
                if (ShipsXML != null)
                {
                    return(ShipsXML.Descendants("Ship"));
                }
                break;

            case TranslationType.ShipTypes:
                if (ShipTypesXML != null)
                {
                    return(ShipTypesXML.Descendants("Type"));
                }
                break;

            case TranslationType.Equipment:
                if (EquipmentXML != null)
                {
                    return(EquipmentXML.Descendants("Item"));
                }
                break;

            case TranslationType.OperationMaps:
                if (OperationsXML != null)
                {
                    return(OperationsXML.Descendants("Map"));
                }
                break;

            case TranslationType.OperationSortie:
                if (OperationsXML != null)
                {
                    return(OperationsXML.Descendants("Sortie"));
                }
                break;

            case TranslationType.Quests:
            case TranslationType.QuestTitle:
            case TranslationType.QuestDetail:
                if (QuestsXML != null)
                {
                    return(QuestsXML.Descendants("Quest"));
                }
                break;

            case TranslationType.Expeditions:
            case TranslationType.ExpeditionTitle:
            case TranslationType.ExpeditionDetail:
                if (ExpeditionsXML != null)
                {
                    return(ExpeditionsXML.Descendants("Expedition"));
                }
                break;
            }

            return(null);
        }
Ejemplo n.º 4
0
        public async Task TranslateDescription_DescriptionCanBeTranslated_ReturnedPokemonHasTranlatedDescription()
        {
            string description = "Hello, good evening and welcome.";

            Domain.Pokemon pokemon = new Domain.Pokemon("n", new TranslatedText(description), "h", true);

            TranslationType translationType = TranslationType.Yoda;

            _mockTranslationTypeDecider.Setup(ttd => ttd.DecideTranslationType(pokemon))
            .Returns(translationType);

            string translatedDescription = "Welcome, good evening and hello";

            _mockTranslator.Setup(t => t.Read(It.IsAny <TranslationRequest>()))
            .ReturnsAsync(new TranslationResult()
            {
                Contents = new Contents()
                {
                    Translated = translatedDescription
                }
            });

            Domain.Pokemon translatedPokemon = await _translationService.TranslateDescription(pokemon);

            Assert.AreEqual(translatedDescription, translatedPokemon.Description.Text);
        }
Ejemplo n.º 5
0
        private Translation GetTranslationFromCache(string key, string langCode, TranslationType type)
        {
            var         cachekey = GetCacheKey(key, langCode, type);
            Translation value    = _memoryCache.Get(cachekey) as Translation;

            return(value);
        }
Ejemplo n.º 6
0
        private IEnumerable <XElement> GetTranslationList(TranslationType type)
        {
            switch (type)
            {
            case TranslationType.Ships:
                if (this.shipsXml != null)
                {
                    return(this.shipsXml.Descendants("Ship"));
                }
                break;

            case TranslationType.ShipTypes:
                if (this.shipTypesXml != null)
                {
                    return(this.shipTypesXml.Descendants("Type"));
                }
                break;

            case TranslationType.Equipment:
                if (this.equipmentXml != null)
                {
                    return(this.equipmentXml.Descendants("Item"));
                }
                break;

            case TranslationType.OperationMaps:
                if (this.operationsXml != null)
                {
                    return(this.operationsXml.Descendants("Map"));
                }
                break;

            case TranslationType.OperationSortie:
                if (this.operationsXml != null)
                {
                    return(this.operationsXml.Descendants("Sortie"));
                }
                break;

            case TranslationType.Quests:
            case TranslationType.QuestTitle:
            case TranslationType.QuestDetail:
                if (this.questsXml != null)
                {
                    return(this.questsXml.Descendants("Quest"));
                }
                break;

            case TranslationType.Expeditions:
            case TranslationType.ExpeditionTitle:
            case TranslationType.ExpeditionDetail:
                if (this.expeditionsXml != null)
                {
                    return(this.expeditionsXml.Descendants("Expedition"));
                }
                break;
            }

            return(null);
        }
        public void DecideTranslationType_CaveHabitat_TranslatorTypeEqualsYoda()
        {
            var             pokemon         = new Domain.Pokemon("name", new TranslatedText("description"), "cave", false);
            TranslationType translationType = _translatorFactory.DecideTranslationType(pokemon);

            Assert.AreEqual(TranslationType.Yoda, translationType);
        }
        public void DecideTranslationType_IsLegendary_TranslatorTypeEqualsYoda()
        {
            var             pokemon         = new Domain.Pokemon("name", new TranslatedText("description"), "waters-edge", true);
            TranslationType translationType = _translatorFactory.DecideTranslationType(pokemon);

            Assert.AreEqual(TranslationType.Yoda, translationType);
        }
        public void DecideTranslationType_NotLegendaryOrCaveHabitat_TranslatorTypeEqualsShakespeare(string habitat)
        {
            var             pokemon         = new Domain.Pokemon("name", new TranslatedText("description"), habitat, false);
            TranslationType translationType = _translatorFactory.DecideTranslationType(pokemon);

            Assert.AreEqual(TranslationType.Shakespeare, translationType);
        }
Ejemplo n.º 10
0
 public MoveToPositionAction(Waypoint pointA, Waypoint pointB, Waypoint pointC, Waypoint pointD, float duration, bool smooth, bool _mustWait) : base(true, _mustWait)
 {
     _type     = TranslationType.LERP_CUBIC_BEZIER;
     _points   = new Waypoint[] { pointA, pointB, pointC, pointD };
     _duration = duration;
     _smooth   = smooth;
 }
Ejemplo n.º 11
0
 public DocumentUploaded(Guid aggregateId, Guid userId, TranslationType translationType, string translationSubject, string fileName) : base(aggregateId, 1)
 {
     TranslationType    = translationType;
     TranslationSubject = translationSubject;
     FileName           = fileName;
     UserId             = userId.ToString();
 }
Ejemplo n.º 12
0
        /// <summary>
        ///     翻译方法 中文:"zh-cn", 英文:"en" type:MircsoftTanslater,GoogleTanslater
        /// </summary>
        /// <param name="sourceText">翻译原文</param>
        /// <param name="fromLanguage">原始语言</param>
        /// <param name="toLanguage">目标语言</param>
        /// <param name="type">翻译API</param>
        /// <returns>译文</returns>
        public static string Translate(string sourceText, LanguageType fromLanguage, LanguageType toLanguage,
                                       TranslationType type = TranslationType.Bing)
        {
            if (string.IsNullOrEmpty(sourceText) || sourceText.Trim() == String.Empty)
            {
                return("");
            }

            string translateStr = string.Empty;

            switch (type)
            {
            case TranslationType.Bing:
                translateStr = MircsoftTanslater(sourceText, fromLanguage, toLanguage);     //"zh-cn", "en";
                break;

            case TranslationType.Google:
                translateStr = GoogleTranslaterGetMethod(sourceText, fromLanguage, toLanguage);     //"zh-cn", "en";
                break;

            case TranslationType.Baidu:
                translateStr = BaiduTranslaterGetMethod(sourceText, fromLanguage, toLanguage);     //"zh-cn", "en";
                break;
            }
            return(translateStr);
        }
Ejemplo n.º 13
0
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="bActive"></param>
        /// <returns></returns>
        /// <created>UPh,25.12.2015</created>
        /// <changed>UPh,25.12.2015</changed>
        // ********************************************************************************
        public override void ActivateTransConnection(string id, TranslationType type, bool bActive)
        {
            if (_TermBaseSet == null)
            {
                InitializeTermbase();
            }

            if (_TermBaseSet == null)
            {
                return;
            }

            int termbaseid;

            if (!int.TryParse(id, out termbaseid))
            {
                return;
            }

            TermBaseFile file = _TermBaseSet.FindTermBaseID(termbaseid);

            if (file == null)
            {
                return;
            }

            file.Active = bActive;
        }
Ejemplo n.º 14
0
        public string GetMapNodes(int mapAreaId, int mapInfoId, int mapNodeId, TranslationType type, int id = -1)
        {
            try
            {
                var translationList = GetTranslationList(type);

                if (translationList == null)
                {
                    return(mapNodeId.ToString());
                }

                var idChildElement    = "Node";
                var labelChildElement = "Label";

                var nodeinfo  = mapAreaId.ToString("D3") + mapInfoId.ToString("D3") + mapNodeId.ToString("D3");
                var converted = nodeinfo;
                if (GetTranslation(nodeinfo, translationList, idChildElement, labelChildElement, id, ref converted))
                {
                    return(converted);
                }
            }
            catch (Exception e)
            {
                Logger.Add(3, "Can't output translation: " + e.Message);
            }

            return(mapNodeId.ToString());
        }
Ejemplo n.º 15
0
 public Translation(string obfName, LookupType type)
 {
     ObfName   = obfName;
     CleanName = type.Name;
     _type     = type;
     Type      = TranslationType.TypeTranslation;
 }
Ejemplo n.º 16
0
        public async Task Remove(string key, string langCode, TranslationType type)
        {
            var translation = await _unitOfWork.Set <Translation>().FirstOrDefaultAsync(x => x.Key == key && x.Language.Code == langCode && x.Type == type);

            _unitOfWork.Set <Translation>().Remove(translation);
            _memoryCache.Remove(key + langCode);
        }
Ejemplo n.º 17
0
        public string GetTranslation(string jpString, TranslationType type, int id = -1)
        {
            try
            {
                IEnumerable <XElement> translationList = this.GetTranslationList(type);

                if (translationList == null)
                {
                    return(jpString);
                }

                string jpChildElement = "JP-Name";
                string trChildElement = "TR-Name";

                if (type == TranslationType.QuestDetail || type == TranslationType.ExpeditionDetail)
                {
                    jpChildElement = "JP-Detail";
                    trChildElement = "TR-Detail";
                }

                string translated = jpString;
                if (this.GetTranslation(jpString, translationList, jpChildElement, trChildElement, id, ref translated))
                {
                    return(translated);
                }
            }
            catch (Exception e)
            {
                Logger.Add(3, "Can't output translation: " + e.Message);
            }

            return(jpString);
        }
Ejemplo n.º 18
0
 public Translation(string obfName, LookupField field)
 {
     ObfName   = obfName;
     CleanName = field.Name;
     _field    = field;
     Type      = TranslationType.FieldTranslation;
 }
        public string GetTranslation(string jpString, TranslationType type, int id = -1)
        {
            try
            {
                IEnumerable<XElement> translationList = this.GetTranslationList(type);

                if (translationList == null) return jpString;

                string jpChildElement = "JP-Name";
                string trChildElement = "TR-Name";

                if (type == TranslationType.QuestDetail || type == TranslationType.ExpeditionDetail)
                {
                    jpChildElement = "JP-Detail";
                    trChildElement = "TR-Detail";
                }

                string translated = jpString;
                if (this.GetTranslation(jpString, translationList, jpChildElement, trChildElement, id, ref translated))
                {
                    return translated;
                }
            }
            catch (Exception e)
            {
                Logger.Add(3, "Can't output translation: " + e.Message);
            }

            return jpString;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Uses the downloaded Version XML document to return a specific version number as a string.
        /// </summary>
        /// <param name="Type">Translation file type. Can also be for the App itself.</param>
        /// <param name="bGetURL">If true, returns the URL of the online file instead of the version.</param>
        /// <returns>String value of either the Version or URL to the file.</returns>
        public string GetOnlineVersion(TranslationType Type, bool bGetURL = false)
        {
            if (VersionXML == null)
                return "";

            IEnumerable<XElement> Versions = VersionXML.Root.Descendants("Item");
            string ElementName =  !bGetURL ? "Version" : "URL";

            switch (Type)
            {
                case TranslationType.App:
                    return Versions.Where(x => x.Element("Name").Value.Equals("App")).FirstOrDefault().Element(ElementName).Value;
                case TranslationType.Equipment:
                    return Versions.Where(x => x.Element("Name").Value.Equals("Equipment")).FirstOrDefault().Element(ElementName).Value;
                case TranslationType.Operations:
                case TranslationType.OperationSortie:
                case TranslationType.OperationMaps:
                    return Versions.Where(x => x.Element("Name").Value.Equals("Operations")).FirstOrDefault().Element(ElementName).Value;
                case TranslationType.Quests:
                case TranslationType.QuestDetail:
                case TranslationType.QuestTitle:
                    return Versions.Where(x => x.Element("Name").Value.Equals("Quests")).FirstOrDefault().Element(ElementName).Value;
                case TranslationType.Ships:
                    return Versions.Where(x => x.Element("Name").Value.Equals("Ships")).FirstOrDefault().Element(ElementName).Value;
                case TranslationType.ShipTypes:
                    return Versions.Where(x => x.Element("Name").Value.Equals("ShipTypes")).FirstOrDefault().Element(ElementName).Value;

            }
            return "";
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Conditional function to determine whether the supplied version is greater than the one found online.
        /// </summary>
        /// <param name="Type">Translation file type. Can also be for the App itself.</param>
        /// <param name="LocalVersionString">Version string of the local file to check against</param>
        /// <returns></returns>
        public bool IsOnlineVersionGreater(TranslationType Type, string LocalVersionString)
        {
            if (VersionXML == null)
                return true;

            IEnumerable<XElement> Versions = VersionXML.Root.Descendants("Item");
            string ElementName = "Version";
            Version LocalVersion = new Version(LocalVersionString);

            switch (Type)
            {
                case TranslationType.App:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("App")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Equipment:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Equipment")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Operations:
                case TranslationType.OperationSortie:
                case TranslationType.OperationMaps:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Operations")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Quests:
                case TranslationType.QuestDetail:
                case TranslationType.QuestTitle:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Quests")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Ships:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Ships")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.ShipTypes:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("ShipTypes")).FirstOrDefault().Element(ElementName).Value)) < 0;

            }

            return false;
        }
        private void ImportTranslation(string path, bool interlinear = false, TranslationType type = TranslationType.Default, bool catolic = false, bool recommended = false)
        {
            ConnectionHelper.Connect();
            var uow = new UnitOfWork();

            uow.BeginTransaction();

            Translation trans = null;

            if (interlinear)
            {
                trans = new TranslationImporter().ImportInterlinear(path, uow);
            }
            else
            {
                trans = new TranslationImporter().Import(path, uow);
            }

            if (trans.IsNotNull())
            {
                trans.Type        = type;
                trans.Recommended = recommended;
                trans.Catolic     = catolic;
            }

            uow.CommitChanges();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Conditional function to determine whether the supplied version is greater than the one found online.
        /// </summary>
        /// <param name="Type">Translation file type. Can also be for the App itself.</param>
        /// <param name="LocalVersionString">Version string of the local file to check against</param>
        /// <returns></returns>
        public bool IsOnlineVersionGreater(TranslationType Type, string LocalVersionString)
        {
            if (VersionXML == null)
            {
                return(true);
            }

            IEnumerable <XElement> Versions = VersionXML.Root.Descendants("Item");
            string ElementName = "Version";

            if (LocalVersionString == "알 수 없음")
            {
                return(false);
            }
            else if (LocalVersionString == "없음")
            {
                return(false);
            }
            Version LocalVersion = new Version(LocalVersionString);


            switch (Type)
            {
            case TranslationType.App:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("App")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.Equipment:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Equipment")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.Operations:
            case TranslationType.OperationSortie:
            case TranslationType.OperationMaps:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Operations")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.Quests:
            case TranslationType.QuestDetail:
            case TranslationType.QuestTitle:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Quests")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.Expeditions:
            case TranslationType.ExpeditionTitle:
            case TranslationType.ExpeditionDetail:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Expeditions")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.Ships:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Ships")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.ShipTypes:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("ShipTypes")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.RemodelSlots:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("RemodelSlots")).FirstOrDefault().Element(ElementName).Value)) < 0);

            case TranslationType.EquipmentTypes:
                return(LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("EquipmentTypes")).FirstOrDefault().Element(ElementName).Value)) < 0);
            }

            return(false);
        }
Ejemplo n.º 24
0
 public Translation CreateInstance(TranslationType translationType)
 {
     if (!this.HasData)
     {
         return(null);
     }
     return(new Translation(this.TranslationID, translationType ?? new TranslationType(this.TranslationTypeID), this.Name, this.Description, this.Updated, this.Created));
 }
Ejemplo n.º 25
0
 public MoveToPositionAction(Waypoint pointA, Waypoint pointB, Waypoint pointC, float duration, bool smooth, bool _mustWait) : base(true, _mustWait)
 {
     _type      = TranslationType.LERP_QUADRATIC_BEZIER;
     _points    = new Waypoint[] { pointA, pointB, pointC };
     _modifiers = null;
     _duration  = duration;
     _smooth    = smooth;
 }
Ejemplo n.º 26
0
        private void SetCacheForNotVerifiedItem(string key, string langCode, TranslationType type)
        {
            var translation = new Translation()
            {
                Key = key, Value = key, Type = type, IsVerified = false
            };

            SetCache(key, translation, langCode, type);
        }
Ejemplo n.º 27
0
        public MoveToPositionAction(Waypoint positionFrom, Waypoint positionTo, float duration, bool smooth, bool _mustWait) : base(true, _mustWait)
        {
            _type      = TranslationType.LERP;
            _points    = new Waypoint[] { positionFrom, positionTo };
            _modifiers = null;

            _duration = duration;
            _smooth   = smooth;
        }
Ejemplo n.º 28
0
        public MoveToPositionAction(Waypoint targetPosition) : base(false, false)
        {
            _type      = TranslationType.SET;
            _points    = new Waypoint[] { targetPosition };
            _modifiers = null;

            _duration = 0;
            _smooth   = false;
        }
Ejemplo n.º 29
0
 public TranslationRequest(TranslationType type, string text)
 {
     if (type == TranslationType.None)
     {
         throw new ArgumentOutOfRangeException("type", "Translation type cannot be None");
     }
     Type = type;
     Text = text;
 }
Ejemplo n.º 30
0
 public LyricsForSong(Song song, string val, string source, string url, TranslationType translationType, string cultureCode)
 {
     Song            = song;
     Source          = source;
     URL             = url;
     TranslationType = translationType;
     CultureCode     = new OptionalCultureCode(cultureCode);
     Value           = val;
 }
Ejemplo n.º 31
0
 public TranslationItem(string name, string property, string source, string oldSource, string value, TranslationType status)
 {
     _name      = name;
     _property  = property;
     _source    = source;
     _oldSource = oldSource;
     _value     = value;
     _status    = status;
 }
Ejemplo n.º 32
0
        public string GetTranslation(string JPString, TranslationType Type, Object RawData, int ID = -1)
        {
            if (!EnableTranslations || CurrentCulture == "ja-JP")
            {
                return(JPString);
            }

            try
            {
                IEnumerable <XElement> TranslationList = GetTranslationList(Type);

                if (TranslationList == null)
                {
                    AddTranslation(RawData, Type);
                    return(JPString);
                }

                string JPChildElement = "JP-Name";
                string TRChildElement = "TR-Name";

                if (Type == TranslationType.QuestDetail)
                {
                    JPChildElement = "JP-Detail";
                    TRChildElement = "TR-Detail";
                }

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

                foreach (XElement el in FoundTranslation)
                {
// #if DEBUG
//                  if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
//                      Debug.WriteLine(string.Format("Translation: {0,-20} {1,-20} {2}", JPString, el.Element(TRChildElement).Value, ID));
// #endif
                    if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
                    {
                        return(el.Element(TRChildElement).Value);
                    }
                    else if (ID < 0)
                    {
                        return(el.Element(TRChildElement).Value);
                    }
                }
#if DEBUG
                Debug.WriteLine(string.Format("Can't find Translation: {0,-20} {1}", JPString, ID));
#endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            AddTranslation(RawData, Type);

            return(JPString);
        }
Ejemplo n.º 33
0
        private void SetCache(string key, Translation value, string langCode, TranslationType type)
        {
            var options = new MemoryCacheEntryOptions()
            {
                AbsoluteExpiration = DateTime.Now.AddMinutes(30),
            };
            var cachekey = GetCacheKey(key, langCode, type);

            _memoryCache.Set(cachekey, value, options);
        }
Ejemplo n.º 34
0
 public Item(string id, string title, PluginMediaType type, IPluginContainer parent, TranslationType translation, string url)
 {
     _id = id;
     if (!string.IsNullOrEmpty(parent.Id))
         _id = parent.Id + "_" + id;
     _title = title;
     _type = type;
     _parent = parent;
     _url = url;
     Translation = translation;
 }
Ejemplo n.º 35
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="bActive"></param>
        /// <returns></returns>
        /// <created>UPh,25.12.2015</created>
        /// <changed>UPh,25.12.2015</changed>
        // ********************************************************************************
        public override void ActivateTransConnection(string id, TranslationType type, bool bActive)
        {
            if (_TermBaseSet == null)
                InitializeTermbase();

            if (_TermBaseSet == null)
                return;

            int termbaseid;
            if (!int.TryParse(id, out termbaseid))
                return;

            TermBaseFile file = _TermBaseSet.FindTermBaseID(termbaseid);
            if (file == null)
                return;

            file.Active = bActive;
        }
Ejemplo n.º 36
0
 public TorrentItem(string id, string title, PluginMediaType type, IPluginContainer parent, TranslationType translation, string url) : base(id, title, type, parent, translation, "")
 {
     _itemurl = url;
     Translation = TranslationType.VoD;
 }
Ejemplo n.º 37
0
 public HasTranslatablePropertiesAttribute(TranslationType translationType)
 {
     Translation = translationType;
 }
Ejemplo n.º 38
0
        public void AddTranslation(Object rawData, TranslationType type)
        {
            if (rawData == null || !this.EnableAddUntranslated)
                return;

            try
            {
                switch (type)
                {
                    case TranslationType.Ships:
                        if (this.shipsXml == null)
                        {
                            this.shipsXml = new XDocument();
                            this.shipsXml.Add(new XElement("Ships"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.shipsXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.ShipsVersion = "0.0.0";
                        }

                        kcsapi_mst_ship shipData = rawData as kcsapi_mst_ship;

                        if (shipData == null)
                            return;

                        // ReSharper disable once PossibleNullReferenceException
                        this.shipsXml.Root.Add(new XElement("Ship",
                            new XElement("JP-Name", shipData.api_name),
                            new XElement("TR-Name", shipData.api_name)
                        ));

                        this.shipsXml.Save("Translations\\Ships.xml");
                        break;

                    case TranslationType.ShipTypes:
                        if (this.shipTypesXml == null)
                        {
                            this.shipTypesXml = new XDocument();
                            this.shipTypesXml.Add(new XElement("ShipTypes"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.shipTypesXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.ShipTypesVersion = "0.0.0";
                        }

                        kcsapi_mst_stype typeData = rawData as kcsapi_mst_stype;

                        if (typeData == null)
                            return;

                        // ReSharper disable once PossibleNullReferenceException
                        this.shipTypesXml.Root.Add(new XElement("Type",
                            new XElement("ID", typeData.api_id),
                            new XElement("JP-Name", typeData.api_name),
                            new XElement("TR-Name", typeData.api_name)
                            ));

                        this.shipTypesXml.Save("Translations\\ShipTypes.xml");
                        break;

                    case TranslationType.Equipment:
                        if (this.equipmentXml == null)
                        {
                            this.equipmentXml = new XDocument();
                            this.equipmentXml.Add(new XElement("Equipment"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.equipmentXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.EquipmentVersion = "0.0.0";
                        }

                        kcsapi_mst_slotitem eqiupData = rawData as kcsapi_mst_slotitem;

                        if (eqiupData == null)
                            return;

                        // ReSharper disable once PossibleNullReferenceException
                        this.equipmentXml.Root.Add(new XElement("Item",
                            new XElement("JP-Name", eqiupData.api_name),
                            new XElement("TR-Name", eqiupData.api_name)
                            ));

                        this.equipmentXml.Save("Translations\\Equipment.xml");
                        break;

                    case TranslationType.OperationMaps:
                    case TranslationType.OperationSortie:
                        if (this.operationsXml == null)
                        {
                            this.operationsXml = new XDocument();
                            this.operationsXml.Add(new XElement("Operations"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.operationsXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.OperationsVersion = "0.0.0";
                        }

                        kcsapi_battleresult operationsData = rawData as kcsapi_battleresult;

                        if (operationsData == null)
                            return;

                        if (type == TranslationType.OperationMaps)
                        {
                            // ReSharper disable once PossibleNullReferenceException
                            this.operationsXml.Root.Add(new XElement("Map",
                                new XElement("JP-Name", operationsData.api_quest_name),
                                new XElement("TR-Name", operationsData.api_quest_name)
                                ));
                        }
                        else
                        {
                            // ReSharper disable once PossibleNullReferenceException
                            this.operationsXml.Root.Add(new XElement("Sortie",
                                new XElement("JP-Name", operationsData.api_enemy_info.api_deck_name),
                                new XElement("TR-Name", operationsData.api_enemy_info.api_deck_name)
                                ));
                        }

                        this.operationsXml.Save("Translations\\Operations.xml");
                        break;

                    case TranslationType.Quests:
                    case TranslationType.QuestTitle:
                    case TranslationType.QuestDetail:
                        if (this.questsXml == null)
                        {
                            this.questsXml = new XDocument();
                            this.questsXml.Add(new XElement("Quests"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.questsXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.QuestsVersion = "0.0.0";
                        }

                        kcsapi_quest questData = rawData as kcsapi_quest;

                        if (questData == null)
                            return;

                        IEnumerable<XElement> foundTranslation = this.questsXml.Descendants("Quest").Where(
                            b => b.Element("ID") != null && b.Element("JP-Name") != null && b.Element("JP-Detail") != null && b.Element("ID").Value.Equals(questData.api_no.ToString())
                        );

                        // ReSharper disable PossibleMultipleEnumeration
                        if (foundTranslation.Any())
                        {
                            foreach (XElement el in foundTranslation)
                            {
                                if (el.Element("JP-Name") == null) el.Add(new XElement("JP-Name", questData.api_title));
                                else el.Element("JP-Name").Value = questData.api_title;
                                if (el.Element("JP-Detail") == null) el.Add(new XElement("JP-Detail", questData.api_detail));
                                else el.Element("JP-Detail").Value = questData.api_detail;
                            }
                        }
                        else
                        {
                            int n;
                            bool needAdd = true;
                            IEnumerable<XElement> foundTranslationDetail = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(questData.api_detail));
                            IEnumerable<XElement> foundTranslationTitle = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(questData.api_title));

                            // Check the current list for any errors and fix them before writing a whole new element.
                            if (type == TranslationType.QuestTitle && foundTranslationDetail.Any())
                            {
                                // The title is wrong, but the detail is right. Fix the title.
                                foreach (XElement el in foundTranslationDetail)
                                {
                                    if (!Int32.TryParse(el.Element("ID").Value, out n))
                                    {
                                        if (el.Element("JP-Name") == null) el.Add(new XElement("JP-Name", questData.api_title));
                                        else el.Element("JP-Name").Value = questData.api_title;
                                        needAdd = false;
                                    }
                                }

                            }
                            else if (type == TranslationType.QuestDetail && foundTranslationTitle.Any())
                            {
                                // We found an existing detail, the title must be broken. Fix it.
                                foreach (XElement el in foundTranslationTitle)
                                {
                                    if (!Int32.TryParse(el.Element("ID").Value, out n))
                                    {
                                        if (el.Element("JP-Detail") == null) el.Add(new XElement("JP-Detail", questData.api_detail));
                                        else el.Element("JP-Detail").Value = questData.api_detail;
                                        needAdd = false;
                                    }
                                }
                            }

                            if (needAdd)
                            {
                                // The quest doesn't exist at all. Add it.
                                // ReSharper disable once PossibleNullReferenceException
                                this.questsXml.Root.Add(new XElement("Quest",
                                    new XElement("ID", questData.api_no),
                                    new XElement("JP-Name", questData.api_title),
                                    new XElement("TR-Name", questData.api_title),
                                    new XElement("JP-Detail", questData.api_detail),
                                    new XElement("TR-Detail", questData.api_detail)
                                    ));
                            }
                        }
                        // ReSharper restore PossibleMultipleEnumeration

                        this.questsXml.Save("Translations\\Quests.xml");
                        break;
                    case TranslationType.Expeditions:
                    case TranslationType.ExpeditionTitle:
                    case TranslationType.ExpeditionDetail:
                        if (this.expeditionsXml == null)
                        {
                            this.expeditionsXml = new XDocument();
                            this.expeditionsXml.Add(new XElement("Expeditions"));
                            // ReSharper disable once PossibleNullReferenceException
                            this.expeditionsXml.Root.SetAttributeValue("Version", "0.0.0");
                            this.ExpeditionsVersion = "0.0.0";
                        }

                        kcsapi_mission expeditionData = rawData as kcsapi_mission;

                        if (expeditionData == null)
                            return;

                        IEnumerable<XElement> foundTranslationExpedition = this.expeditionsXml.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(expeditionData.api_id.ToString()));

                        // Check the current list for any errors and fix them before writing a whole new element.
                        // ReSharper disable PossibleMultipleEnumeration
                        if (foundTranslationExpedition.Any())
                        {
                            foreach (var el in foundTranslationExpedition)
                            {
                                if (el.Element("JP-Name") == null) el.Add(new XElement("JP-Name", expeditionData.api_name));
                                else el.Element("JP-Name").Value = expeditionData.api_name;
                                if (el.Element("JP-Detail") == null) el.Add(new XElement("JP-Detail", expeditionData.api_details));
                                else el.Element("JP-Detail").Value = expeditionData.api_details;
                            }

                        }
                        else
                        {
                            // The quest doesn't exist at all. Add it.
                            // ReSharper disable once PossibleNullReferenceException
                            this.expeditionsXml.Root.Add(new XElement("Expedition",
                                new XElement("ID", expeditionData.api_id),
                                new XElement("JP-Name", expeditionData.api_name),
                                new XElement("TR-Name", expeditionData.api_name),
                                new XElement("JP-Detail", expeditionData.api_details),
                                new XElement("TR-Detail", expeditionData.api_details)
                                ));
                        }

                        this.expeditionsXml.Save("Translations\\Expeditions.xml");
                        // ReSharper restore PossibleMultipleEnumeration
                        break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Ejemplo n.º 39
0
 public YoutubeItem(string id, string title, PluginMediaType type, IPluginContainer parent, TranslationType translation, string url) : base(id, title, type, parent, translation, "")
 {
     ItemUrl = url;
 }
Ejemplo n.º 40
0
 public HlslAttribute(string translation, TranslationType translation_type) { }
Ejemplo n.º 41
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;
 }
Ejemplo n.º 42
0
        public string GetTranslation(string JPString, TranslationType Type, bool IsLogReader, Object RawData = null, int ID = -1)
        {
            if (!EnableTranslations)
                return JPString;

            try
            {
                IEnumerable<XElement> TranslationList = GetTranslationList(Type);

                if (TranslationList == null && RawData != null)
                {
                    if (!IsLogReader) AddTranslation(RawData, Type);
                    if (ID < 0 && !IsLogReader) return "[" + ID.ToString() + "] " + JPString;
                    else return JPString;
                }

                string JPChildElement = "JP-Name";
                string TRChildElement = "TR-Name";
                string IDElement = "ID";

                if (Type == TranslationType.QuestDetail || Type == TranslationType.ExpeditionDetail)
                {
                    JPChildElement = "JP-Detail";
                    TRChildElement = "TR-Detail";
                }

                IEnumerable<XElement> OldFoundTranslation = TranslationList.Where(b => b.Element(JPChildElement).Value.Equals(JPString));//string 비교검색
                if (ID < 0)//일반적 번역
                {
                    foreach (XElement el in OldFoundTranslation)
                    {
                        return el.Element(TRChildElement).Value;
                    }
                }
                else//퀘스트,원정 번역
                {
                    IEnumerable<XElement> FoundTranslation = TranslationList.Where(b => b.Element(IDElement).Value.Equals(ID.ToString()));//퀘스트 ID검색

                    foreach (XElement el in FoundTranslation)
                    {
            #if DEBUG
                    if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
                        Debug.WriteLine(string.Format("Translation: {0,-20} {1,-20} {2}", JPString, el.Element(TRChildElement).Value, ID));
            #endif
                        if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
                            return el.Element(TRChildElement).Value;

                    }
                    foreach (XElement el in OldFoundTranslation)
                    {
                        return el.Element(TRChildElement).Value;
                    }
                }

            #if DEBUG
                Debug.WriteLine(string.Format("Can't find Translation: {0,-20} {1}", JPString, ID));
            #endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            if (RawData != null && !IsLogReader) AddTranslation(RawData, Type);
            if (ID < 0 && IsLogReader) return JPString;
            else return "[" + ID.ToString() + "] " + JPString;
        }
Ejemplo n.º 43
0
 private int UpdateFile(bool checkVersion, WebClient client, string culture, string path, TranslationType translationType, string version)
 {
     if (checkVersion && !this.IsOnlineVersionGreater(translationType, version)) return 0;
     var file = Path.Combine(directory, culture, path);
     var tmpFile = Path.Combine(tmpDirectory, path);
     var url = this.GetOnlineVersion(translationType, true);
     if (culture.Length > 0) url = new Uri(new Uri(url), "./" + culture + "/" + path).ToString();
     client.DownloadFile(url, tmpFile);
     try
     {
         if (File.Exists(file)) File.Delete(file);
         File.Move(tmpFile, file);
         return 1;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
         return -1;
     }
 }
Ejemplo n.º 44
0
        private IEnumerable<XElement> GetTranslationList(TranslationType type)
        {
            switch(type)
            {
                case TranslationType.Ships:
                    if (this.shipsXml != null)
                        return this.shipsXml.Descendants("Ship");
                    break;
                case TranslationType.ShipTypes:
                    if (this.shipTypesXml != null)
                        return this.shipTypesXml.Descendants("Type");
                    break;
                case TranslationType.Equipment:
                    if (this.equipmentXml != null)
                        return this.equipmentXml.Descendants("Item");
                    break;
                case TranslationType.OperationMaps:
                    if (this.operationsXml != null)
                        return this.operationsXml.Descendants("Map");
                    break;
                case TranslationType.OperationSortie:
                    if (this.operationsXml != null)
                        return this.operationsXml.Descendants("Sortie");
                    break;
                case TranslationType.Quests:
                case TranslationType.QuestTitle:
                case TranslationType.QuestDetail:
                    if (this.questsXml != null)
                        return this.questsXml.Descendants("Quest");
                    break;
                case TranslationType.Expeditions:
                case TranslationType.ExpeditionTitle:
                case TranslationType.ExpeditionDetail:
                    if (this.expeditionsXml != null)
                        return this.expeditionsXml.Descendants("Expedition");
                    break;
            }

            return null;
        }
Ejemplo n.º 45
0
        public string GetTranslation(string jpString, TranslationType type, Object rawData, int id = -1)
        {
            if (!this.EnableTranslations || this.currentCulture == "ja-JP")
                return jpString;

            try
            {
                IEnumerable<XElement> translationList = this.GetTranslationList(type);

                if (translationList == null)
                {
                    return jpString;
                }

                string jpChildElement = "JP-Name";
                string trChildElement = "TR-Name";

                if (type == TranslationType.QuestDetail || type == TranslationType.ExpeditionDetail)
                {
                    jpChildElement = "JP-Detail";
                    trChildElement = "TR-Detail";
                }

                string translate = jpString;
                if (this.GetTranslation(jpString, translationList, jpChildElement, trChildElement, id, ref translate))
                {
                    return translate;
                }
            #if DEBUG
                Debug.WriteLine("Can't find Translation: {0,-20} {1}", jpString, id);
            #endif
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return jpString;
        }
Ejemplo n.º 46
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;
        }
Ejemplo n.º 47
0
 private IEnumerable<XElement> GetTranslationList(TranslationType Type)
 {
     switch (Type)
     {
         case TranslationType.Ships:
             if (ShipsXML != null)
             {
                 if (KanColleClient.Current.Updater.ShipsUpdate)
                 {
                     this.ShipsXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Ships.xml"));
                     KanColleClient.Current.Updater.ShipsUpdate = false;
                 }
                 return ShipsXML.Descendants("Ship");
             }
             break;
         case TranslationType.ShipTypes:
             if (ShipTypesXML != null)
             {
                 if (KanColleClient.Current.Updater.ShipTypesUpdate)
                 {
                     this.ShipTypesXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "ShipTypes.xml"));
                     KanColleClient.Current.Updater.ShipTypesUpdate = false;
                 }
                 return ShipTypesXML.Descendants("Type");
             }
             break;
         case TranslationType.Equipment:
             if (EquipmentXML != null)
             {
                 if (KanColleClient.Current.Updater.EquipUpdate)
                 {
                     this.EquipmentXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Equipment.xml"));
                     KanColleClient.Current.Updater.EquipUpdate = false;
                 }
                 return EquipmentXML.Descendants("Item");
             }
             break;
         case TranslationType.OperationMaps:
             if (OperationsXML != null)
             {
                 if (KanColleClient.Current.Updater.OperationsUpdate)
                 {
                     this.OperationsXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Operations.xml"));
                     KanColleClient.Current.Updater.OperationsUpdate = false;
                 }
                 return OperationsXML.Descendants("Map");
             }
             break;
         case TranslationType.OperationSortie:
             if (OperationsXML != null)
             {
                 if (KanColleClient.Current.Updater.OperationsUpdate)
                 {
                     this.OperationsXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Operations.xml"));
                     KanColleClient.Current.Updater.OperationsUpdate = false;
                 }
                 return OperationsXML.Descendants("Sortie");
             }
             break;
         case TranslationType.Quests:
         case TranslationType.QuestTitle:
         case TranslationType.QuestDetail:
             if (QuestsXML != null)
             {
                 if (KanColleClient.Current.Updater.QuestUpdate)
                 {
                     this.QuestsXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Quests.xml"));
                     KanColleClient.Current.Updater.QuestUpdate = false;
                 }
                 return QuestsXML.Descendants("Quest");
             }
             break;
         case TranslationType.Expeditions:
         case TranslationType.ExpeditionTitle:
         case TranslationType.ExpeditionDetail:
             if (ExpeditionXML != null)
             {
                 if (KanColleClient.Current.Updater.ExpeditionUpdate)
                 {
                     this.ExpeditionXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "Expeditions.xml"));
                     KanColleClient.Current.Updater.ExpeditionUpdate = false;
                 }
                 return ExpeditionXML.Descendants("Expedition");
             }
             break;
     }
     return null;
 }
Ejemplo n.º 48
0
 private int XmlFileWizard(string MainFolder, string Xmlname, TranslationType type)
 {
     int ReturnValue;
     try
     {
         if (File.Exists(Path.Combine(MainFolder, "Translations", Xmlname)))
         {
             if (File.Exists(Path.Combine(MainFolder, "Translations", "Old", Xmlname + ".old")))
                 File.Delete(Path.Combine(MainFolder, "Translations", "Old", Xmlname + ".old"));
             File.Move(Path.Combine(MainFolder, "Translations", Xmlname), Path.Combine(MainFolder, "Translations", "Old", Xmlname + ".old"));
         }
         File.Move(Path.Combine(MainFolder, "Translations", "tmp", Xmlname), Path.Combine(MainFolder, "Translations", Xmlname));
         ReturnValue = 1;
         UpdateState(ReturnValue, type);
     }
     catch
     {
         ReturnValue = -1;
     }
     return ReturnValue;
 }
Ejemplo n.º 49
0
		public void AddTranslation(Object RawData, TranslationType Type)
		{
			if (RawData == null || !EnableAddUntranslated)
				return;

			try
			{
				switch (Type)
				{
					case TranslationType.Ships:
						if (ShipsXML == null)
						{
							ShipsXML = new XDocument();
							ShipsXML.Add(new XElement("Ships"));
							ShipsXML.Root.SetAttributeValue("Version", "0.0.0");
							ShipsVersion = "0.0.0";
						}

						kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship;

						if (ShipData == null)
							return;

						ShipsXML.Root.Add(new XElement("Ship",
							new XElement("JP-Name", ShipData.api_name),
							new XElement("TR-Name", ShipData.api_name)
						));

						ShipsXML.Save("Translations\\" + CurrentCulture + "Ships.xml");
						break;

					case TranslationType.ShipTypes:
						if (ShipTypesXML == null)
						{
							ShipTypesXML = new XDocument();
							ShipTypesXML.Add(new XElement("ShipTypes"));
							ShipTypesXML.Root.SetAttributeValue("Version", "0.0.0");
							ShipTypesVersion = "0.0.0";
						}

						kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype;

						if (TypeData == null)
							return;

						ShipTypesXML.Root.Add(new XElement("Type",
							new XElement("ID", TypeData.api_id),
							new XElement("JP-Name", TypeData.api_name),
							new XElement("TR-Name", TypeData.api_name)
							));

						ShipTypesXML.Save("Translations\\" + CurrentCulture + "ShipTypes.xml");
						break;

					case TranslationType.Equipment:
						if (EquipmentXML == null)
						{
							EquipmentXML = new XDocument();
							EquipmentXML.Add(new XElement("Equipment"));
							EquipmentXML.Root.SetAttributeValue("Version", "0.0.0");
							EquipmentVersion = "0.0.0";
						}

						kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem;

						if (EqiupData == null)
							return;

						EquipmentXML.Root.Add(new XElement("Item",
							new XElement("JP-Name", EqiupData.api_name),
							new XElement("TR-Name", EqiupData.api_name)
							));

						EquipmentXML.Save("Translations\\" + CurrentCulture + "Equipment.xml");
						break;

					case TranslationType.OperationMaps:
					case TranslationType.OperationSortie:
						if (OperationsXML == null)
						{
							OperationsXML = new XDocument();
							OperationsXML.Add(new XElement("Operations"));
							OperationsXML.Root.SetAttributeValue("Version", "0.0.0");
							OperationsVersion = "0.0.0";
						}

						kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult;

						if (OperationsData == null)
							return;

						if (Type == TranslationType.OperationMaps)
						{
							OperationsXML.Root.Add(new XElement("Map",
								new XElement("JP-Name", OperationsData.api_quest_name),
								new XElement("TR-Name", OperationsData.api_quest_name)
								));
						}
						else
						{
							OperationsXML.Root.Add(new XElement("Sortie",
								new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name),
								new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name)
								));
						}

						OperationsXML.Save("Translations\\" + CurrentCulture + "Operations.xml");
						break;

					case TranslationType.Quests:
					case TranslationType.QuestTitle:
					case TranslationType.QuestDetail:
						if (QuestsXML == null)
						{
							QuestsXML = new XDocument();
							QuestsXML.Add(new XElement("Quests"));
							QuestsXML.Root.SetAttributeValue("Version", "0.0.0");
							QuestsVersion = "0.0.0";
						}

						kcsapi_quest QuestData = RawData as kcsapi_quest;

						if (QuestData == null)
							return;

						IEnumerable<XElement> FoundTranslationDetail = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(QuestData.api_detail));
						IEnumerable<XElement> FoundTranslationTitle = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(QuestData.api_title));

						// Check the current list for any errors and fix them before writing a whole new element.
						if (Type == TranslationType.QuestTitle && FoundTranslationDetail != null && FoundTranslationDetail.Any())
						{
							// The title is wrong, but the detail is right. Fix the title.
							foreach (XElement el in FoundTranslationDetail)
								el.Element("JP-Name").Value = QuestData.api_title;

						}
						else if (Type == TranslationType.QuestDetail && FoundTranslationTitle != null && FoundTranslationTitle.Any())
						{
							// We found an existing detail, the title must be broken. Fix it.
							foreach (XElement el in FoundTranslationTitle)
								el.Element("JP-Detail").Value = QuestData.api_detail;
						}
						else
						{
							// The quest doesn't exist at all. Add it.
							QuestsXML.Root.Add(new XElement("Quest",
								new XElement("ID", QuestData.api_no),
								new XElement("JP-Name", QuestData.api_title),
								new XElement("TR-Name", QuestData.api_title),
								new XElement("JP-Detail", QuestData.api_detail),
								new XElement("TR-Detail", QuestData.api_detail)
								));
						}

						QuestsXML.Save("Translations\\" + CurrentCulture + "Quests.xml");
						break;
				}
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);
			}
		}
Ejemplo n.º 50
0
        public string ReplaceTranslation(string JPString, TranslationType type = TranslationType.PartTranslate)
        {
            string stemp = JPString;
            try
            {
                string JPChildElement = "JPstring";
                string TRChildElement = "TRstring";

                IEnumerable<XElement> TranslationList = GetTranslationList(type);

                foreach (var item in TranslationList)
                {
                    if (stemp.Contains(item.Element(JPChildElement).Value))
                    {
                        stemp = stemp.Replace(item.Element(JPChildElement).Value, item.Element(TRChildElement).Value);
                    }

                }
                return stemp;
            }
            catch { }
            return JPString;
        }
Ejemplo n.º 51
0
		private IEnumerable<XElement> GetTranslationList(TranslationType Type)
		{
			switch(Type)
			{
				case TranslationType.Ships:
					if (ShipsXML != null) 
						return ShipsXML.Descendants("Ship");
					break;
				case TranslationType.ShipTypes:
					if (ShipTypesXML != null) 
						return ShipTypesXML.Descendants("Type");
					break;
				case TranslationType.Equipment:
					if (EquipmentXML != null) 
						return EquipmentXML.Descendants("Item");
					break;
				case TranslationType.OperationMaps:
					if (OperationsXML != null) 
						return OperationsXML.Descendants("Map");
					break;
				case TranslationType.OperationSortie:
					if (OperationsXML != null) 
						return OperationsXML.Descendants("Sortie");
					break;
				case TranslationType.Quests:
				case TranslationType.QuestTitle:
				case TranslationType.QuestDetail:
					if (QuestsXML != null) 
						return QuestsXML.Descendants("Quest");
					break;
			}

			return null;
		}
Ejemplo n.º 52
0
        public void AddTranslation(Object RawData, TranslationType Type)
        {
            if (RawData == null || !EnableAddUntranslated)
                return;

            try
            {
                switch (Type)
                {
                    case TranslationType.Ships:
                        if (ShipsXML == null)
                        {
                            ShipsXML = new XDocument();
                            ShipsXML.Add(new XElement("Ships"));
                        }

                        kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship;

                        if (ShipData == null)
                            return;

                        ShipsXML.Root.Add(new XElement("Ship",
                            new XElement("JP-Name", ShipData.api_name),
                            new XElement("TR-Name", ShipData.api_name)
                        ));

                        ShipsXML.Save(Path.Combine(MainFolder, "Translations", "Ships.xml"));
                        break;

                    case TranslationType.ShipTypes:
                        if (ShipTypesXML == null)
                        {
                            ShipTypesXML = new XDocument();
                            ShipTypesXML.Add(new XElement("ShipTypes"));
                        }

                        kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype;

                        if (TypeData == null)
                            return;

                        ShipTypesXML.Root.Add(new XElement("Type",
                            new XElement("ID", TypeData.api_id),
                            new XElement("JP-Name", TypeData.api_name),
                            new XElement("TR-Name", TypeData.api_name)
                            ));

                        ShipTypesXML.Save(Path.Combine(MainFolder, "Translations", "ShipTypes.xml"));
                        break;

                    case TranslationType.Equipment:
                        if (EquipmentXML == null)
                        {
                            EquipmentXML = new XDocument();
                            EquipmentXML.Add(new XElement("Equipment"));
                        }

                        kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem;

                        if (EqiupData == null)
                            return;

                        EquipmentXML.Root.Add(new XElement("Item",
                            new XElement("JP-Name", EqiupData.api_name),
                            new XElement("TR-Name", EqiupData.api_name)
                            ));

                        EquipmentXML.Save(Path.Combine(MainFolder, "Translations", "Equipment.xml"));
                        break;

                    case TranslationType.OperationMaps:
                    case TranslationType.OperationSortie:
                        if (OperationsXML == null)
                        {
                            OperationsXML = new XDocument();
                            OperationsXML.Add(new XElement("Operations"));
                        }

                        kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult;

                        if (OperationsData == null)
                            return;

                        if (Type == TranslationType.OperationMaps)
                        {
                            OperationsXML.Root.Add(new XElement("Map",
                                new XElement("JP-Name", OperationsData.api_quest_name),
                                new XElement("TR-Name", OperationsData.api_quest_name)
                                ));
                        }
                        else
                        {
                            OperationsXML.Root.Add(new XElement("Sortie",
                                new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name),
                                new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name)
                                ));
                        }

                        OperationsXML.Save(Path.Combine(MainFolder, "Translations", "Operations.xml"));
                        break;

                    case TranslationType.Quests:
                    case TranslationType.QuestTitle:
                    case TranslationType.QuestDetail:
                        if (QuestsXML == null)
                        {
                            QuestsXML = new XDocument();
                            QuestsXML.Add(new XElement("Quests"));
                        }

                        kcsapi_quest QuestData = RawData as kcsapi_quest;

                        if (QuestData == null)
                            return;

                        IEnumerable<XElement> FoundTranslationID = QuestsXML.Descendants("Quest").Where(b => b.Element("ID").Value.Equals(QuestData.api_no));
                        //이 부분에 의심이 가지만 확증은 없음
                        if (Type == TranslationType.QuestTitle || Type == TranslationType.QuestDetail && FoundTranslationID != null && FoundTranslationID.Any())
                        {
                            foreach (XElement el in FoundTranslationID)
                                el.Element("ID").Value = QuestData.api_no.ToString();

                        }
                        else
                        {
                            // The quest doesn't exist at all. Add it.
                            QuestsXML.Root.Add(new XElement("Quest",
                                new XElement("ID", QuestData.api_no),
                                new XElement("JP-Name", QuestData.api_title),
                                new XElement("TR-Name", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_title),
                                new XElement("JP-Detail", QuestData.api_detail),
                                new XElement("TR-Detail", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_detail)
                                ));
                        }

                        QuestsXML.Save(Path.Combine(MainFolder, "Translations", "Quests.xml"));
                        break;
                    case TranslationType.Expeditions:
                    case TranslationType.ExpeditionTitle:
                    case TranslationType.ExpeditionDetail:
                        if (ExpeditionXML == null)
                        {
                            ExpeditionXML = new XDocument();
                            ExpeditionXML.Add(new XElement("Expeditions"));
                        }

                        kcsapi_mission MissionData = RawData as kcsapi_mission;

                        if (MissionData == null)
                            return;

                        FoundTranslationID = ExpeditionXML.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(MissionData.api_id));
                        if (Type == TranslationType.ExpeditionTitle || Type == TranslationType.ExpeditionDetail && FoundTranslationID != null && FoundTranslationID.Any())
                        {
                            foreach (XElement el in FoundTranslationID)
                                el.Element("ID").Value = MissionData.api_id.ToString();

                        }
                        else
                        {
                            // The quest doesn't exist at all. Add it.
                            ExpeditionXML.Root.Add(new XElement("Expedition",
                            new XElement("ID", MissionData.api_id),
                            new XElement("JP-Name", MissionData.api_name),
                            new XElement("TR-Name", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_name),
                            new XElement("JP-Detail", MissionData.api_details),
                            new XElement("TR-Detail", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_details)
                            ));
                        }

                        ExpeditionXML.Save(Path.Combine(MainFolder, "Translations", "Expeditions.xml"));
                        break;
                }
            }
            catch { }
        }
Ejemplo n.º 53
0
		public string GetTranslation(string JPString, TranslationType Type, Object RawData, int ID = -1)
		{
			if (!EnableTranslations || CurrentCulture == "ja-JP")
				return JPString;

			try
			{
				IEnumerable<XElement> TranslationList = GetTranslationList(Type);

				if (TranslationList == null)
				{
					AddTranslation(RawData, Type);
					return JPString;
				}

				string JPChildElement = "JP-Name";
				string TRChildElement = "TR-Name";

				if (Type == TranslationType.QuestDetail)
				{
					JPChildElement = "JP-Detail";
					TRChildElement = "TR-Detail";
				}

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

				foreach (XElement el in FoundTranslation)
				{
// #if DEBUG
// 					if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
// 						Debug.WriteLine(string.Format("Translation: {0,-20} {1,-20} {2}", JPString, el.Element(TRChildElement).Value, ID));
// #endif
					if (ID >= 0 && el.Element("ID") != null && Convert.ToInt32(el.Element("ID").Value) == ID)
						return el.Element(TRChildElement).Value;
					else if (ID < 0)
						return el.Element(TRChildElement).Value;

				}
#if DEBUG
				Debug.WriteLine(string.Format("Can't find Translation: {0,-20} {1}", JPString, ID));
#endif
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);
			}

			AddTranslation(RawData, Type);

			return JPString;
		}
Ejemplo n.º 54
0
 /// <summary>
 /// 업데이트 상태를 구별한다.
 /// bool값을 조정하며 이는 업데이트 후 바로 퀘스트 로드가 적용되지 않는 문제점을 자체 해결하기 위해 도입한것임.
 /// </summary>
 /// <param name="ReturnVal">-1,0,1을 받는다. 사실상 별 의미 없는거같기도</param>
 /// <param name="type">업데이트 된 항목이 정확히 무엇인지 구별한다</param>
 /// <returns></returns>
 public void UpdateState(int ReturnVal, TranslationType type)
 {
     if (ReturnVal == 1)
     {
         switch (type)
         {
             case TranslationType.Equipment:
                 this.EquipUpdate = true;
                 break;
             case TranslationType.Operations:
                 this.OperationsUpdate = true;
                 break;
             case TranslationType.Quests:
                 this.QuestUpdate = true;
                 break;
             case TranslationType.Ships:
                 this.ShipsUpdate = true;
                 break;
             case TranslationType.ShipTypes:
                 this.ShipTypesUpdate = true;
                 break;
             case TranslationType.Expeditions:
                 this.ExpeditionUpdate = true;
                 break;
             case TranslationType.RemodelSlots:
                 this.RemodelUpdate = true;
                 break;
         }
     }
 }