コード例 #1
0
        public void TestAshcanPete_ShowsCorrectText()
        {
            String    dictEntry = "INVESTIGATOR_ASHCAN_PETE,\"\"\"Ashcan\"\" Pete\",Pete Cubo de Basura,\"\"\"Ashcan\"\" Pete\",„Ashcan“ Pete,“Ashcan” Pete,Peter “Chaminé”,Pete „Włóczęga”,ごみあさりのピート,“灰堆”皮特";
            EntryI18n actual    = new EntryI18n(dict, dictEntry);

            Assert.AreEqual("\"Ashcan\" Pete", actual.currentLanguageString);
        }
コード例 #2
0
        public void RenamePrefix(string oldPrefix, string newPrefix)
        {
            HashSet <string> toRemove = new HashSet <string>();
            List <EntryI18n> toAdd    = new List <EntryI18n>();

            foreach (string s in dict.Keys)
            {
                if (s.IndexOf(oldPrefix) == 0)
                {
                    string    newKey = newPrefix + s.Substring(oldPrefix.Length);
                    EntryI18n e      = dict[s];
                    e.key = newKey;
                    toAdd.Add(e);
                    toRemove.Add(s);
                }
            }
            foreach (string s in toRemove)
            {
                Remove(s);
            }
            foreach (EntryI18n e in toAdd)
            {
                dict.Add(e.key, e);
            }
            for (int i = 0; i < rawDict.Length; i++)
            {
                if (rawDict[i].IndexOf(oldPrefix) == 0)
                {
                    rawDict[i] = newPrefix + rawDict[i].Substring(oldPrefix.Length);
                }
            }
        }
コード例 #3
0
        public void TestQuotesWithoutComma_DoesntSplit()
        {
            String    dictEntry    = ".,\"\",,,,,,,,";
            EntryI18n actual       = new EntryI18n(dict, dictEntry);
            String    actualString = actual.currentLanguageString;
            String    expected     = "";

            Assert.AreEqual(expected, actualString);
        }
コード例 #4
0
        public void TestLangsString_LoadsLastLanguage()
        {
            dict.currentLanguage = 9;
            EntryI18n actual       = new EntryI18n(dict, DictionaryI18n.FFG_LANGS);
            String    actualString = actual.currentLanguageString;
            String    expected     = "Chinese";

            dict.setCurrentLanguage(DictionaryI18n.DEFAULT_LANG);
            Assert.AreEqual(expected, actualString);
        }
コード例 #5
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 (!dicts["qst"].tryGetValue(key, out entry))
            {
                // if not exists, we create a new one
                entry = new EntryI18n(key, dicts["qst"]);
            }

            entry.currentLanguageString = text;
        }
コード例 #6
0
        public void TestDifferentLangInserts_DoesntOverwriteOtherLangTexts()
        {
            String    dictEntry = ".,,,,,,,,,";
            EntryI18n actual    = new EntryI18n(dict, dictEntry);

            for (int nLang = 1; nLang < 10; nLang++)
            {
                // First language
                dict.currentLanguage         = nLang;
                actual.currentLanguageString = nLang.ToString();
            }

            for (int nLang = 1; nLang < 10; nLang++)
            {
                // Back to first
                dict.currentLanguage = nLang;
                Assert.AreEqual(nLang.ToString(), actual.currentLanguageString);
            }
        }
コード例 #7
0
ファイル: DictionaryI18n.cs プロジェクト: foskon/valkyrie
        /// <summary>
        /// Checks if a key exists in the dictionary
        /// gets its value
        /// </summary>
        /// <param name="v">key to find</param>
        /// <param name="valueOut">variable to store result if exists</param>
        /// <returns>true if the key exists in the dictionary</returns>
        public bool tryGetValue(string v, out EntryI18n valueOut)
        {
            bool found = dict.TryGetValue(v, out valueOut);

            if (found)
            {
                return(true);
            }
            else
            {
                // Search element
                for (int pos = 1; pos < rawDict.Length; pos++)
                {
                    // if the line is not empty and not slash (/) insert
                    if (rawDict[pos].StartsWith(v + COMMA))
                    {
                        valueOut = new EntryI18n(this, GetEntry(pos));
                        Add(valueOut);
                        return(true);
                    }
                }
                return(false);
            }
        }
コード例 #8
0
ファイル: DictionaryI18n.cs プロジェクト: foskon/valkyrie
 /// <summary>
 /// Create a dict entry with the StringI18n
 /// </summary>
 /// <param name="currentKeyValues">line of localization file</param>
 public void Add(EntryI18n currentKeyValues)
 {
     dict.Add(currentKeyValues.key, currentKeyValues);
 }
コード例 #9
0
 /// <summary>
 /// Create a dict entry with the StringI18n
 /// </summary>
 /// <param name="currentKeyValues">line of localization file</param>
 public void Add(EntryI18n currentKeyValues)
 {
     dict[currentKeyValues.key] = currentKeyValues;
 }