Ejemplo n.º 1
0
        public void TestByakhee()
        {
            EntryI18n value;

            sut.tryGetValue("MONSTER_BYAKHEE_ATTACK_01", out value);
            Assert.IsNotNull(value.getCurrentOrDefaultLanguageString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets a dictionary entry for key and text.Creates or replaces
        /// </summary>
        /// <param name="key">key of the string</param>
        /// <param name="text">text to insert in current language</param>
        public static void updateScenarioText(string key, string text)
        {
            EntryI18n entry;

            // Search for localization string
            if (!scenarioDict.tryGetValue(key, out entry))
            {
                // if not exists, we create a new one
                entry = new EntryI18n(key, scenarioDict);
            }

            entry.currentLanguageString = text;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Transform a ffg key (without ffg prefig, into current language text
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        private static string FFGKeyLookup(string key)
        {
            if (ffgDict != null)
            {
                //try
                //{
                EntryI18n valueOut;

                if (ffgDict.tryGetValue(key, out valueOut))
                {
                    return(valueOut.getCurrentOrDefaultLanguageString());
                }
                else
                {
                    return(key);
                }
                //}

                /*catch (System.Exception e)
                 * {
                 *  ValkyrieDebug.Log("Warning: Unable to process imported Localization string with key: " + key + ". Exception:" + e.Message + System.Environment.NewLine);
                 * }*/
            }
            else
            {
                ValkyrieDebug.Log("Error: FFG dictionary not loaded");
            }
            return(key);
        }
Ejemplo n.º 4
0
        private static bool CheckDictQuery(string dict, string input)
        {
            int           bracketLevel = 0;
            int           lastSection  = 0;
            List <string> elements     = new List <string>();

            // Separate the input into sections
            for (int index = 0; index < input.Length; index++)
            {
                if (input[index].Equals('{'))
                {
                    bracketLevel++;
                }
                if (input[index].Equals('}'))
                {
                    bracketLevel--;
                }
                // Section divider
                if (input[index].Equals(':'))
                {
                    // Not in brackets
                    if (bracketLevel == 0)
                    {
                        // Add previous element
                        elements.Add(input.Substring(lastSection, index - lastSection));
                        lastSection = index + 1;
                    }
                }
            }
            // Add previous element
            elements.Add(input.Substring(lastSection, input.Length - lastSection));

            DictionaryI18n currentDict = selectDictionary(dict);

            if (currentDict == null)
            {
                return(false);
            }
            EntryI18n valueOut;

            return(currentDict.tryGetValue(elements[0], out valueOut));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Transform a ffg key (without ffg prefig, into current language text
        /// </summary>
        /// <param name="dict"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        private static string DictKeyLookup(string dict, string key)
        {
            DictionaryI18n currentDict = selectDictionary(dict);

            if (currentDict != null)
            {
                EntryI18n valueOut;

                if (currentDict.tryGetValue(key, out valueOut))
                {
                    return(valueOut.getCurrentOrDefaultLanguageString());
                }
                else
                {
                    return(key);
                }
            }
            else
            {
                ValkyrieDebug.Log("Error: current dictionary not loaded");
            }
            return(key);
        }