summaryrefslogtreecommitdiff
path: root/tools/Langpack Suite/Searcher.cs
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-05-21 07:42:17 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-05-21 07:42:17 +0000
commitb630b8222027387a769605d8feac4cc0f406a50b (patch)
tree3fbacd3bd931e10850c148a78d996ada74d73879 /tools/Langpack Suite/Searcher.cs
parente3c5e2d3c36dded39795fb065b382452a9259084 (diff)
added Langpack Suite
git-svn-id: http://svn.miranda-ng.org/main/trunk@115 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'tools/Langpack Suite/Searcher.cs')
-rw-r--r--tools/Langpack Suite/Searcher.cs280
1 files changed, 280 insertions, 0 deletions
diff --git a/tools/Langpack Suite/Searcher.cs b/tools/Langpack Suite/Searcher.cs
new file mode 100644
index 0000000000..a34b1c4628
--- /dev/null
+++ b/tools/Langpack Suite/Searcher.cs
@@ -0,0 +1,280 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Windows.Forms;
+using System.Globalization;
+using System.Resources;
+
+namespace Langpack_Suite
+{
+ class Searcher
+ {
+ private CultureInfo culture;
+ List<string> str = new List<string>();
+ List<string> dup = new List<string>();
+ public string filename;
+ public byte mode = 1;
+ MainForm _mainForm;
+
+ public Searcher(MainForm mainForm)
+ {
+ _mainForm = mainForm;
+ }
+
+ public void DupesSearch()
+ {
+ string s = "";
+ int i = 0;
+ str.Clear();
+ dup.Clear();
+ StreamReader fstr_in = new StreamReader(filename);
+ while ((s = fstr_in.ReadLine()) != null)
+ {
+ Console.WriteLine(s);
+ if (s.StartsWith("["))
+ {
+ str.Add(s);
+ i += 1;
+ }
+ else if ((s.StartsWith(";")) && (s.Contains("[")))
+ {
+ int q = s.IndexOf("[");
+ s = s.Remove(0, q);
+ int qq = s.LastIndexOf("]");
+ s += " ";
+ s = s.Remove(qq + 1);
+ str.Add(s);
+ }
+ }
+ fstr_in.Close();
+ for (i = 0; i <= str.Count - 1; i++)
+ {
+ for (int j = 0; j <= str.Count - 1; j++)
+ {
+ if ((str[i].Equals(str[j])) && (i != j))
+ {
+ if (dup.Count == 0)
+ {
+ dup.Add(str[i]);
+ }
+ else
+ {
+ int k = 0;
+ for (int z = 0; z <= dup.Count - 1; z++)
+ {
+ if (str[i].Equals(dup[z]))
+ {
+ k += 1;
+ }
+ }
+ if (k == 0)
+ {
+ dup.Add(str[i]);
+ }
+ }
+ }
+ }
+ }
+ ResourceManager rm;
+ string LocaleText;
+ if (_mainForm.LanguageComboBox.SelectedIndex == 0)
+ culture = CultureInfo.CreateSpecificCulture("en-EN");
+ if (_mainForm.LanguageComboBox.SelectedIndex == 1)
+ culture = CultureInfo.CreateSpecificCulture("ru-RU");
+ if (dup.Count > 0)
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("DupFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ if (mode == 1)
+ {
+ StreamWriter fstr_out = new StreamWriter(filename + "_dupes");
+ for (i = 0; i <= dup.Count - 1; i++)
+ {
+ try
+ {
+ fstr_out.Write(dup[i] + "\r\n");
+ }
+ catch (IOException)
+ {
+ LocaleText = rm.GetString("NotWrite", culture);
+ string LocaleText2 = rm.GetString("Error", culture);
+ MessageBox.Show(LocaleText, LocaleText2, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ fstr_out.Close();
+ LocaleText = rm.GetString("Done", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ //автоматический поиск и удаление дублей
+ }
+ }
+ else
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("DupNotFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+
+ public void NotTransSearch()
+ {
+ string s = "", ss = "";
+ str.Clear();
+ dup.Clear();
+ StreamReader fstr_in = new StreamReader(filename);
+ while ((s = fstr_in.ReadLine()) != null)
+ {
+ Console.WriteLine(s);
+ str.Add(s);
+ }
+ fstr_in.Close();
+ for (int i = 0; i <= str.Count - 1; i++)
+ {
+ if (i == str.Count - 1)
+ {
+ s = str[i].ToString();
+ if (s.StartsWith("["))
+ {
+ dup.Add(str[i]);
+ }
+ }
+ else
+ {
+ s = str[i].ToString();
+ ss = str[i + 1].ToString();
+ if ((s.StartsWith("[")) && (ss.StartsWith("[")))
+ {
+ dup.Add(str[i]);
+ }
+ }
+ }
+ ResourceManager rm;
+ string LocaleText;
+ if (_mainForm.LanguageComboBox.SelectedIndex == 0)
+ culture = CultureInfo.CreateSpecificCulture("en-EN");
+ if (_mainForm.LanguageComboBox.SelectedIndex == 1)
+ culture = CultureInfo.CreateSpecificCulture("ru-RU");
+ if (dup.Count > 0)
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("NotTransFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ if (mode == 1)
+ {
+ StreamWriter fstr_out = new StreamWriter(filename + "_ntrans");
+ for (int i = 0; i <= dup.Count - 1; i++)
+ {
+ try
+ {
+ fstr_out.Write(dup[i] + "\r\n");
+ }
+ catch (IOException)
+ {
+ LocaleText = rm.GetString("NotWrite", culture);
+ string LocaleText2 = rm.GetString("Error", culture);
+ MessageBox.Show(LocaleText, LocaleText2, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ fstr_out.Close();
+ LocaleText = rm.GetString("Done", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ //автоматический поиск и удаление не переведенных строк
+ }
+ }
+ else
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("NotTransNotFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ public void CommentsSearch()
+ {
+ string s = "";
+ str.Clear();
+ dup.Clear();
+ StreamReader fstr_in = new StreamReader(filename);
+ while ((s = fstr_in.ReadLine()) != null)
+ {
+ Console.WriteLine(s);
+ str.Add(s);
+ }
+ fstr_in.Close();
+ for (int i = 0; i <= str.Count - 1; i++)
+ {
+ s = str[i].ToString();
+ if ((s.StartsWith(";")) && (s.Contains("[")))
+ {
+ dup.Add(str[i]);
+ }
+ }
+ ResourceManager rm;
+ string LocaleText;
+ if (_mainForm.LanguageComboBox.SelectedIndex == 0)
+ culture = CultureInfo.CreateSpecificCulture("en-EN");
+ if (_mainForm.LanguageComboBox.SelectedIndex == 1)
+ culture = CultureInfo.CreateSpecificCulture("ru-RU");
+ if (dup.Count > 0)
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("ComFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ if (mode == 1)
+ {
+ StreamWriter fstr_out = new StreamWriter(filename + "_com");
+ for (int i = 0; i <= dup.Count - 1; i++)
+ {
+ try
+ {
+ fstr_out.Write(dup[i] + "\r\n");
+ }
+ catch (IOException)
+ {
+ LocaleText = rm.GetString("NotWrite", culture);
+ string LocaleText2 = rm.GetString("Error", culture);
+ MessageBox.Show(LocaleText, LocaleText2, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ }
+ fstr_out.Close();
+ LocaleText = rm.GetString("Done", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ //автоматический поиск и удаление закомментированных строк
+ }
+ }
+ else
+ {
+ rm = new ResourceManager("LangpackSuite.myRes", typeof(MainForm).Assembly);
+ LocaleText = rm.GetString("ComNotFound", culture);
+ _mainForm.InfMessageFindBox.Text = _mainForm.InfMessageFindBox.Text + LocaleText + "\r\n";
+ string LocaleText3 = rm.GetString("Inf", culture);
+ MessageBox.Show(LocaleText, LocaleText3, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ }
+}
+