Ejemplo n.º 1
0
 private static void Load()
 {
     TextTranslator.StopWatchTextFiles();
     TextTranslator.mainfilefullpath = null;
     TextTranslator.translationsLv.Clear();
     TextTranslator.translationsLvR.Clear();
     TextTranslator.translations.Clear();
     TextTranslator.translationsR.Clear();
     if (File.Exists(TextTranslator.MainFilePath))
     {
         TextTranslator.LoadTranslations(TextTranslator.MainFilePath, false);
     }
     if (TextTranslator.GlobalTextDir != TextTranslator.TextDir)
     {
         TextTranslator.LoadAllFromGlobalTranslationDir();
     }
     TextTranslator.LoadAllFromTranslationDir();
     TextTranslator.WatchTextFiles();
     if (IniSettings.DebugMode || IniSettings.FindText)
     {
         int count = 0;
         foreach (OrderedDictionary value in TextTranslator.translationsLv.Values)
         {
             count = count + value.Count;
         }
         foreach (List <RegexTranslationData> regexTranslationDatas in TextTranslator.translationsLvR.Values)
         {
             count = count + regexTranslationDatas.Count;
         }
         count = count + TextTranslator.translations.Count;
         count = count + TextTranslator.translationsR.Count;
         IniSettings.Log(string.Format("Translations Loaded: {0}", count));
     }
 }
Ejemplo n.º 2
0
        private static void WatcherNotice(object sender, FileSystemEventArgs e)
        {
            object noticeLock = TextTranslator.NoticeLock;

            Monitor.Enter(noticeLock);
            try
            {
                if (!(TextTranslator.lastraisedfile == e.FullPath) || !(DateTime.Now < TextTranslator.lastraisedtime))
                {
                    TextTranslator.lastraisedfile = e.FullPath;
                    TextTranslator.lastraisedtime = DateTime.Now.AddSeconds(1);
                    if (e.FullPath.EndsWith(".noregex.txt"))
                    {
                        if (!IniSettings.UseRegEx)
                        {
                            TextTranslator.LoadTranslations(e.FullPath, true);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (e.FullPath.EndsWith(".regex.txt"))
                    {
                        if (IniSettings.UseRegEx)
                        {
                            TextTranslator.LoadTranslations(e.FullPath, true);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (e.FullPath != TextTranslator.MainFileFullPath)
                    {
                        string str = e.FullPath.Substring(0, e.FullPath.Length - ".txt".Length);
                        str = string.Concat(str, (IniSettings.UseRegEx ? ".regex.txt" : ".noregex.txt"));
                        if (!File.Exists(str))
                        {
                            TextTranslator.LoadTranslations(e.FullPath, true);
                        }
                        else
                        {
                            TextTranslator.LoadTranslations(e.FullPath, false);
                            TextTranslator.LoadTranslations(str, true);
                        }
                    }
                    else
                    {
                        TextTranslator.LoadTranslations(e.FullPath, true);
                    }
                    TextTranslator.WatchTextFiles();
                }
            }
            finally
            {
                Monitor.Exit(noticeLock);
            }
        }
Ejemplo n.º 3
0
 private static void LoadAllFromTranslationDir(string[] files)
 {
     try
     {
         if (files != null && files.Length != 0)
         {
             HashSet <string> strs      = new HashSet <string>();
             bool             useRegEx  = IniSettings.UseRegEx;
             string[]         strArrays = files;
             for (int i = 0; i < (int)strArrays.Length; i++)
             {
                 string str = strArrays[i];
                 if (!strs.Contains(str))
                 {
                     string str1 = null;
                     if (str.EndsWith(".noregex.txt"))
                     {
                         if (useRegEx)
                         {
                             continue;
                         }
                         str1 = string.Concat(str.Substring(0, str.Length - ".noregex.txt".Length), ".txt");
                     }
                     else if (str.EndsWith(".regex.txt"))
                     {
                         if (!useRegEx)
                         {
                             continue;
                         }
                         str1 = string.Concat(str.Substring(0, str.Length - ".regex.txt".Length), ".txt");
                     }
                     if (!string.IsNullOrEmpty(str1))
                     {
                         if (!strs.Contains(str1) && File.Exists(str1))
                         {
                             TextTranslator.LoadTranslations(str1, false);
                             strs.Add(str1);
                         }
                         TextTranslator.LoadTranslations(str, false);
                         strs.Add(str);
                     }
                     else
                     {
                         TextTranslator.LoadTranslations(str, false);
                         strs.Add(str);
                         str1 = (!useRegEx ? string.Concat(str.Substring(0, str.Length - ".txt".Length), ".noregex.txt") : string.Concat(str.Substring(0, str.Length - ".txt".Length), ".regex.txt"));
                         if (!strs.Contains(str1) && File.Exists(str1))
                         {
                             TextTranslator.LoadTranslations(str1, false);
                             strs.Add(str1);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         IniSettings.Error(string.Concat("TextTranslator::LoadFromTranslationDir:\n", exception.ToString()));
     }
 }