Exemple #1
0
 static TextTranslator()
 {
     TextTranslator.TranslationLock = new object();
     TextTranslator.translationsLv  = new Dictionary <int, OrderedDictionary>();
     TextTranslator.translationsLvR = new Dictionary <int, List <RegexTranslationData> >();
     TextTranslator.translations    = new OrderedDictionary();
     TextTranslator.translationsR   = new List <RegexTranslationData>();
     TextTranslator.NoticeLock      = new object();
     TextTranslator.WriterLock      = new object();
     TextTranslator.Initialize();
 }
Exemple #2
0
        private static void WriterTimerElapsed(object sender, ElapsedEventArgs e)
        {
            object writerLock = TextTranslator.WriterLock;

            Monitor.Enter(writerLock);
            try
            {
                TextTranslator.StopWatchTextFiles();
                try
                {
                    foreach (KeyValuePair <string, StringBuilder> writerdatum in TextTranslator.writerdata)
                    {
                        string key           = writerdatum.Key;
                        string directoryName = Path.GetDirectoryName(key);
                        if (!Directory.Exists(directoryName))
                        {
                            Directory.CreateDirectory(directoryName);
                        }
                        if (!File.Exists(key) && key != TextTranslator.MainFilePath)
                        {
                            string   str       = key.Substring(0, key.Length - ".txt".Length);
                            string[] strArrays = new string[] { string.Concat(str, ".noregex.txt"), string.Concat(str, ".regex.txt") };
                            for (int i = 0; i < (int)strArrays.Length; i++)
                            {
                                string str1 = strArrays[i];
                                if (!File.Exists(str1))
                                {
                                    File.Create(str1).Dispose();
                                }
                            }
                        }
                        using (StreamWriter streamWriter = new StreamWriter(key, true, Encoding.UTF8))
                        {
                            streamWriter.Write(writerdatum.Value.ToString());
                        }
                    }
                }
                catch (Exception exception)
                {
                    IniSettings.Error(string.Concat("TextTranslator::DumpText:\n", exception.ToString()));
                }
                TextTranslator.writerdata.Clear();
                TextTranslator.WatchTextFiles();
            }
            finally
            {
                Monitor.Exit(writerLock);
            }
        }
Exemple #3
0
        private static string Encode(string text)
        {
            string        str           = TextTranslator.HexEncode("//", true);
            string        str1          = '='.ToString();
            string        str2          = TextTranslator.HexEncode(str1, true);
            StringBuilder stringBuilder = new StringBuilder(text);

            stringBuilder.Replace("0x", TextTranslator.HexEncode("x", false));
            if (text.StartsWith("//"))
            {
                stringBuilder.Remove(0, "//".Length);
                stringBuilder.Insert(0, str);
            }
            stringBuilder.Replace(str1, str2);
            stringBuilder.Replace("\r", "\\r");
            stringBuilder.Replace("\n", "\\n");
            stringBuilder.Replace("\t", "\\t");
            return(stringBuilder.ToString());
        }
Exemple #4
0
        public static KeyTranslationData[] FindPredictions(string text, KeyTranslationData[] predictions = null)
        {
            OrderedDictionary orderedDictionaries;
            Dictionary <string, KeyTranslationData> strs = new Dictionary <string, KeyTranslationData>();

            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    if (predictions == null)
                    {
                        if (TextTranslator.translationsLv.TryGetValue(Application.loadedLevel, out orderedDictionaries))
                        {
                            TextTranslator.MakePredictions(text, orderedDictionaries, strs);
                        }
                        TextTranslator.MakePredictions(text, TextTranslator.translations, strs);
                    }
                    else
                    {
                        OrderedDictionary    orderedDictionaries1    = new OrderedDictionary();
                        KeyTranslationData[] keyTranslationDataArray = predictions;
                        for (int i = 0; i < (int)keyTranslationDataArray.Length; i++)
                        {
                            KeyTranslationData keyTranslationDatum = keyTranslationDataArray[i];
                            orderedDictionaries1.Add(keyTranslationDatum.Key, keyTranslationDatum);
                        }
                        TextTranslator.MakePredictions(text, orderedDictionaries1, strs);
                    }
                }
                catch (Exception exception)
                {
                    IniSettings.Error(string.Concat("TextTranslator::PredictTranslation:\n", exception.ToString()));
                }
            }
            KeyTranslationData[] keyTranslationDataArray1 = new KeyTranslationData[strs.Count];
            strs.Values.CopyTo(keyTranslationDataArray1, 0);
            return(keyTranslationDataArray1);
        }
Exemple #5
0
        private void LateUpdate()
        {
            TimeSpan timeSpan;

            if (!TextTranslator.Initialized)
            {
                return;
            }
            if (base.GetType() == typeof(Text))
            {
                try
                {
                    if (MaskableGraphicText.cpy2clip.Count > 0 && (U::UnityEngine.Time.time >= MaskableGraphicText.cliptime || U::UnityEngine.Time.time >= MaskableGraphicText.idlecliptime))
                    {
                        if (MaskableGraphicText.NativeMethods.OpenClipboard(IntPtr.Zero))
                        {
                            if (MaskableGraphicText.NativeMethods.EmptyClipboard())
                            {
                                string empty = string.Empty;
                                foreach (Text text in MaskableGraphicText.cpy2clip)
                                {
                                    if (string.IsNullOrEmpty(text.text4translate))
                                    {
                                        continue;
                                    }
                                    empty = string.Concat(empty, text.text4translate, Environment.NewLine);
                                }
                                uint   length = (uint)((empty.Length + 1) * 2);
                                IntPtr intPtr = MaskableGraphicText.NativeMethods.GlobalAlloc(66, new UIntPtr(length));
                                if (intPtr != IntPtr.Zero)
                                {
                                    IntPtr hGlobalUni = Marshal.StringToHGlobalUni(empty);
                                    IntPtr intPtr1    = MaskableGraphicText.NativeMethods.GlobalLock(intPtr);
                                    if (intPtr1 != IntPtr.Zero)
                                    {
                                        MaskableGraphicText.NativeMethods.CopyMemory(intPtr1, hGlobalUni, length);
                                        MaskableGraphicText.NativeMethods.GlobalUnlock(intPtr1);
                                        MaskableGraphicText.NativeMethods.SetClipboardData(13, intPtr);
                                    }
                                    Marshal.FreeHGlobal(hGlobalUni);
                                    MaskableGraphicText.NativeMethods.GlobalFree(intPtr);
                                }
                            }
                            MaskableGraphicText.NativeMethods.CloseClipboard();
                        }
                        MaskableGraphicText.idlecliptime = 0f;
                        MaskableGraphicText.cliptime     = 0f;
                        MaskableGraphicText.cpy2clip.Clear();
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MaskableGraphicText.idlecliptime = 0f;
                    MaskableGraphicText.cliptime     = 0f;
                    MaskableGraphicText.cpy2clip.Clear();
                    IniSettings.Error(string.Concat("MaskableGraphicText::LateUpdate::Copy2Clipboard:\n", exception.ToString()));
                }
                try
                {
                    if (this.textchanged)
                    {
                        this.textchanged = false;
                        this.textcached  = null;
                        if (!TextTranslator.IsNotValidString(this.text4translate))
                        {
                            if (IniSettings.UseCopy2Clipboard)
                            {
                                timeSpan = (IniSettings.Copy2ClipboardTime >= 1 ? TimeSpan.FromMilliseconds((double)IniSettings.Copy2ClipboardTime) : TimeSpan.FromMilliseconds(1));
                                float single = U::UnityEngine.Time.time + Convert.ToSingle(timeSpan.TotalSeconds);
                                MaskableGraphicText.cliptime = single;
                                if (MaskableGraphicText.idlecliptime == 0f)
                                {
                                    MaskableGraphicText.idlecliptime = single + 3f;
                                }
                                if (!MaskableGraphicText.cpy2clip.Contains((Text)this))
                                {
                                    MaskableGraphicText.cpy2clip.Add((Text)this);
                                }
                            }
                            string value = this.text4translate;
                            if (this.txtpredictions != null || this.firstprediction)
                            {
                                if (this.firstprediction)
                                {
                                    this.firstprediction = false;
                                    this.txtpredictions  = TextTranslator.FindPredictions(this.text4translate, null);
                                }
                                else if ((int)this.txtpredictions.Length > 1)
                                {
                                    this.txtpredictions = TextTranslator.FindPredictions(this.text4translate, this.txtpredictions);
                                }
                                if (this.txtpredictions.Length == 0)
                                {
                                    this.predictionsfailed = true;
                                    this.txtpredictions    = null;
                                    TextTranslator.Translate(ref value);
                                }
                                else if ((int)this.txtpredictions.Length != 1)
                                {
                                    value = this.InitialPrediction();
                                }
                                else if (this.txtpredictions[0].Key.Length > this.text4translate.Length && this.txtpredictions[0].Key.StartsWith(this.text4translate))
                                {
                                    if (!string.IsNullOrEmpty(this.txtpredictions[0].Value))
                                    {
                                        float length1 = (float)this.text4translate.Length / (float)this.txtpredictions[0].Key.Length;
                                        int   num     = Convert.ToInt32((float)this.txtpredictions[0].Value.Length * length1);
                                        value = this.txtpredictions[0].Value.Substring(0, num);
                                        Text text1 = this as Text;
                                        TextTranslator.ApplyFontSettings(text1);
                                        U::UnityEngine.TextGenerationSettings generationSettings = text1.GetGenerationSettings(text1.rectTransform.rect.size);
                                        U::UnityEngine.TextGenerator          textGenerator      = new U::UnityEngine.TextGenerator();
                                        textGenerator.Populate(this.txtpredictions[0].Value, generationSettings);
                                        if (textGenerator.lineCount > 1)
                                        {
                                            int num1 = textGenerator.lineCount - 1;
                                            while (num1 >= 1)
                                            {
                                                U::UnityEngine.UILineInfo item = textGenerator.lines[num1];
                                                if (value.Length < item.startCharIdx)
                                                {
                                                    num1--;
                                                }
                                                else
                                                {
                                                    if (value.Length == item.startCharIdx || value == this.txtpredictions[0].Value || value[item.startCharIdx - 1] == '\n')
                                                    {
                                                        goto Label1;
                                                    }
                                                    value = value.Insert(item.startCharIdx, "\n");
                                                    goto Label1;
                                                }
                                            }
                                        }
                                    }
                                }
                                else if (this.txtpredictions[0].Key != this.text4translate)
                                {
                                    this.predictionsfailed = true;
                                    this.txtpredictions    = null;
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(this.txtpredictions[0].Value))
                                    {
                                        value = this.txtpredictions[0].Value;
                                    }
                                    this.txtpredictions = null;
                                }
                            }
                            else if (!TextTranslator.Translate(ref value) && IniSettings.UseTextPrediction && !this.predictionsfailed)
                            {
                                this.firstprediction = true;
                            }
Label1:
                            if (value != this.text4translate)
                            {
                                value = string.Concat(this.text4translatetag1, value, this.text4translatetag2);
                                this.texttranslated = value;
                                ((Text)this).text   = value;
                                TextTranslator.ApplyFontSettings((Text)this);
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (this.retranslatetext)
                    {
                        this.retranslatetext = false;
                        if (!string.IsNullOrEmpty(this.text4translate))
                        {
                            string str  = this.text4translate;
                            string str1 = this.text2translate;
                            this.ResetTextPredictions();
                            this.text2translate = null;
                            this.text4translate = null;
                            this.texttranslated = null;
                            ((Text)this).text   = str;
                            ((Text)this).text   = str1;
                            this.LateUpdate();
                        }
                    }
                }
                catch (Exception exception3)
                {
                    Exception exception2 = exception3;
                    this.textchanged = false;
                    this.textcached  = null;
                    IniSettings.Error(string.Concat("MaskableGraphicText::LateUpdate:\n", exception2.ToString()));
                }
            }
        }
Exemple #6
0
        public static bool Translate(ref string text)
        {
            OrderedDictionary           orderedDictionaries;
            List <RegexTranslationData> regexTranslationDatas;
            bool flag;
            OrderedDictionary orderedDictionaries1;
            object            translationLock = TextTranslator.TranslationLock;

            Monitor.Enter(translationLock);
            try
            {
                try
                {
                    string value = null;
                    if (TextTranslator.translationsLv.TryGetValue(Application.loadedLevel, out orderedDictionaries))
                    {
                        TranslationDataBase item = orderedDictionaries[text] as TranslationDataBase;
                        if (item == null)
                        {
                            goto Label2;
                        }
                        value = item.Value;
                        goto Label1;
                    }
Label2:
                    if (IniSettings.UseRegEx)
                    {
                        TextTranslator.UpdateRegexCacheSize();
                        if (TextTranslator.translationsLvR.TryGetValue(Application.loadedLevel, out regexTranslationDatas))
                        {
                            foreach (RegexTranslationData regexTranslationDatum in regexTranslationDatas)
                            {
                                Match match = Regex.Match(text, regexTranslationDatum.Key);
                                if (!match.Success || !(match.Groups[0].Value == text))
                                {
                                    continue;
                                }
                                value = match.Result(regexTranslationDatum.Value);
                                goto Label1;
                            }
                        }
                    }
                    TranslationDataBase translationDataBase = TextTranslator.translations[text] as TranslationDataBase;
                    if (translationDataBase != null)
                    {
                        value = translationDataBase.Value;
                    }
                    else if (IniSettings.UseRegEx)
                    {
                        TextTranslator.UpdateRegexCacheSize();
                        foreach (RegexTranslationData regexTranslationDatum1 in TextTranslator.translationsR)
                        {
                            Match match1 = Regex.Match(text, regexTranslationDatum1.Key);
                            if (!match1.Success || !(match1.Groups[0].Value == text))
                            {
                                continue;
                            }
                            value = match1.Result(regexTranslationDatum1.Value);
                            goto Label1;
                        }
                    }
Label1:
                    if (value != null)
                    {
                        if (!string.IsNullOrEmpty(value))
                        {
                            text = value;
                            flag = true;
                            return(flag);
                        }
                    }
                    else if (IniSettings.FindText)
                    {
                        if (!IniSettings.DumpTextByLevel)
                        {
                            string mainFilePath = TextTranslator.MainFilePath;
                            TextTranslator.translations.Add(text, new TranslationDataBase(mainFilePath));
                            TextTranslator.DumpText(mainFilePath, text);
                        }
                        else
                        {
                            if (!TextTranslator.translationsLv.TryGetValue(Application.loadedLevel, out orderedDictionaries1))
                            {
                                orderedDictionaries1 = new OrderedDictionary();
                                TextTranslator.translationsLv.Add(Application.loadedLevel, orderedDictionaries1);
                            }
                            string lvFilePath = TextTranslator.LvFilePath;
                            orderedDictionaries1.Add(text, new TranslationDataBase(lvFilePath));
                            TextTranslator.DumpText(lvFilePath, text);
                        }
                    }
                }
                catch (Exception exception)
                {
                    IniSettings.Error(string.Concat("TextTranslator::Translate:\n", exception.ToString()));
                }
                flag = false;
            }
            finally
            {
                Monitor.Exit(translationLock);
            }
            return(flag);
        }
Exemple #7
0
        private static void LoadTranslations(string file, bool retranslate = false)
        {
            string str             = file;
            object translationLock = TextTranslator.TranslationLock;

            Monitor.Enter(translationLock);
            try
            {
                try
                {
                    if (Path.GetExtension(str).ToLower() == ".txt")
                    {
                        if (!Path.GetFileName(str).StartsWith("."))
                        {
                            if (str.StartsWith(Environment.CurrentDirectory))
                            {
                                str = str.Remove(0, Environment.CurrentDirectory.Length);
                                if (!str.StartsWith("\\"))
                                {
                                    str = string.Concat("\\", str);
                                }
                                str = string.Concat(".", str);
                            }
                            int  fileLevel = TextTranslator.GetFileLevel(str);
                            bool flag      = fileLevel > -1;
                            OrderedDictionary           orderedDictionaries   = null;
                            List <RegexTranslationData> regexTranslationDatas = null;
                            if (!flag)
                            {
                                TextTranslator.RemoveAllTranslation(TextTranslator.translations, str);
                                TextTranslator.translationsR.RemoveAll((RegexTranslationData x) => x.Path == str);
                            }
                            else
                            {
                                TextTranslator.translationsLv.TryGetValue(fileLevel, out orderedDictionaries);
                                TextTranslator.translationsLvR.TryGetValue(fileLevel, out regexTranslationDatas);
                                if (orderedDictionaries != null)
                                {
                                    TextTranslator.RemoveAllTranslation(orderedDictionaries, str);
                                }
                                if (regexTranslationDatas != null)
                                {
                                    regexTranslationDatas.RemoveAll((RegexTranslationData x) => x.Path == str);
                                }
                            }
                            using (StreamReader streamReader = new StreamReader(str, Encoding.UTF8))
                            {
                                RegexOptions regexOption = RegexOptions.None;
                                regexOption = regexOption | RegexOptions.Singleline;
                                regexOption = regexOption | RegexOptions.IgnoreCase;
                                while (!streamReader.EndOfStream)
                                {
                                    string str1 = streamReader.ReadLine();
                                    if (str1.Length == 0 || str1.StartsWith("//"))
                                    {
                                        continue;
                                    }
                                    string[] strArrays = str1.Split(new char[] { '=' }, StringSplitOptions.None);
                                    if ((int)strArrays.Length != 2)
                                    {
                                        if (!IniSettings.FindText)
                                        {
                                            continue;
                                        }
                                        try
                                        {
                                            if (!Directory.Exists(IniSettings.LogFileDir))
                                            {
                                                Directory.CreateDirectory(IniSettings.LogFileDir);
                                            }
                                            if ((int)strArrays.Length <= 2)
                                            {
                                                IniSettings.Log(string.Concat(new string[] { "Error_On__File: ", str, Environment.NewLine, "Unknown__Value: ", str1, Environment.NewLine, Environment.NewLine, Environment.NewLine }));
                                            }
                                            else
                                            {
                                                string[] newLine = new string[] { "Error_On__File: ", str, Environment.NewLine, "SeparatorError: ", str1, Environment.NewLine, "  -> Replace the \"=\" after the first \"=\" by \"", null, null, null, null };
                                                char     chr     = '=';
                                                newLine[7]  = TextTranslator.HexEncode(chr.ToString(), true);
                                                newLine[8]  = "\"";
                                                newLine[9]  = Environment.NewLine;
                                                newLine[10] = Environment.NewLine;
                                                IniSettings.Log(string.Concat(newLine));
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    else
                                    {
                                        TranslationDataBase item = null;
                                        bool   flag1             = false;
                                        string value             = TextTranslator.Decode(strArrays[0].Trim());
                                        if (string.IsNullOrEmpty(value))
                                        {
                                            continue;
                                        }
                                        string str2 = TextTranslator.Decode(strArrays[1].Trim());
                                        if (value[0].ToString().ToUpper() == "R")
                                        {
                                            Match match = Regex.Match(value, "^R\\s*\\((.+)\\)$", regexOption);
                                            if (match.Success)
                                            {
                                                if (!IniSettings.UseRegEx)
                                                {
                                                    continue;
                                                }
                                                flag1 = true;
                                                value = match.Groups[1].Value;
                                            }
                                        }
                                        if (flag1)
                                        {
                                            if (!flag)
                                            {
                                                item = TextTranslator.translationsR.Find((RegexTranslationData t) => t.Key == value);
                                            }
                                            else if (regexTranslationDatas != null)
                                            {
                                                item = regexTranslationDatas.Find((RegexTranslationData t) => t.Key == value);
                                            }
                                        }
                                        else if (!flag)
                                        {
                                            item = TextTranslator.translations[value] as TranslationDataBase;
                                        }
                                        else if (orderedDictionaries != null)
                                        {
                                            item = orderedDictionaries[value] as TranslationDataBase;
                                        }
                                        if (item != null)
                                        {
                                            if (flag1)
                                            {
                                                if (!flag)
                                                {
                                                    TextTranslator.translationsR.Remove((RegexTranslationData)item);
                                                }
                                                else
                                                {
                                                    regexTranslationDatas.Remove((RegexTranslationData)item);
                                                }
                                            }
                                            else if (!flag)
                                            {
                                                TextTranslator.translations.Remove(value);
                                            }
                                            else
                                            {
                                                orderedDictionaries.Remove(value);
                                            }
                                            if (IniSettings.FindText)
                                            {
                                                try
                                                {
                                                    if (!Directory.Exists(IniSettings.LogFileDir))
                                                    {
                                                        Directory.CreateDirectory(IniSettings.LogFileDir);
                                                    }
                                                    string[] value1 = new string[] { "Replacing__Key: ", value, "=", item.Value, Environment.NewLine, "FromLoadedFile: ", item.Path, Environment.NewLine, "By__Next___Key: ", value, "=", str2, Environment.NewLine, "From_Next_File: ", str, Environment.NewLine, "These__Keys_Do: ", null, null, null };
                                                    value1[17] = (item.Value != str2 ? "Not Match" : "Match");
                                                    value1[18] = Environment.NewLine;
                                                    value1[19] = Environment.NewLine;
                                                    IniSettings.Log(string.Concat(value1));
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                        if (!flag1)
                                        {
                                            item = new TranslationDataBase(str, str2);
                                            if (!flag)
                                            {
                                                TextTranslator.translations.Add(value, item);
                                            }
                                            else
                                            {
                                                if (orderedDictionaries == null)
                                                {
                                                    orderedDictionaries = new OrderedDictionary();
                                                    TextTranslator.translationsLv.Add(fileLevel, orderedDictionaries);
                                                }
                                                orderedDictionaries.Add(value, item);
                                            }
                                        }
                                        else
                                        {
                                            try
                                            {
                                                try
                                                {
                                                    item = new RegexTranslationData(str, value, str2);
                                                    TextTranslator.UpdateRegexCacheSize();
                                                    Regex.Replace("A", value, str2);
                                                }
                                                catch (Exception exception1)
                                                {
                                                    Exception exception = exception1;
                                                    item = null;
                                                    if (IniSettings.FindText)
                                                    {
                                                        try
                                                        {
                                                            IniSettings.Log(string.Concat(new string[] { "Error_On__File: ", str, Environment.NewLine, "Regex____Error: ", str1, Environment.NewLine, "  ", exception.Message, Environment.NewLine, Environment.NewLine, Environment.NewLine }));
                                                        }
                                                        catch
                                                        {
                                                        }
                                                    }
                                                }
                                            }
                                            finally
                                            {
                                                if (item != null)
                                                {
                                                    if (!flag)
                                                    {
                                                        TextTranslator.translationsR.Add((RegexTranslationData)item);
                                                    }
                                                    else
                                                    {
                                                        if (regexTranslationDatas == null)
                                                        {
                                                            regexTranslationDatas = new List <RegexTranslationData>();
                                                            TextTranslator.translationsLvR.Add(fileLevel, regexTranslationDatas);
                                                        }
                                                        regexTranslationDatas.Add((RegexTranslationData)item);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (retranslate)
                            {
                                MaskableGraphicText.Retranslate();
                            }
                            if (IniSettings.DebugMode || IniSettings.FindText)
                            {
                                IniSettings.Log(string.Concat("Loaded: ", str));
                            }
                        }
                    }
                }
                catch (Exception exception2)
                {
                    IniSettings.Error(string.Concat("LoadTranslations:\n", exception2.ToString()));
                }
            }
            finally
            {
                Monitor.Exit(translationLock);
            }
        }
Exemple #8
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()));
     }
 }