summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2015-10-29 11:04:42 +0000
committeremkael <emkael@tlen.pl>2015-10-29 11:04:42 +0000
commitd5a48672dc1c3efc366bf18e218159c1d83262e8 (patch)
tree4ca5314cf841215082fe734a76c21578608afaf1
parentaf8aa690aefa4d5e27b56731677bf71d317c5bc1 (diff)
* internationalization of application messages
git-svn-id: https://svn.emkael.info/an9k@63 05ec0d5d-773b-4d93-9e23-c81a7ac79feb
-rw-r--r--Analizator9000/Analizator9000/BCalcWrapper.cs6
-rw-r--r--Analizator9000/Analizator9000/DealerParser.cs8
-rw-r--r--Analizator9000/Analizator9000/DealerWrapper.cs4
-rw-r--r--Analizator9000/Analizator9000/Form1.cs35
-rw-r--r--Analizator9000/Analizator9000/Form1.resx105
-rw-r--r--Analizator9000/Analizator9000/ScoreAccumulator.cs17
6 files changed, 139 insertions, 36 deletions
diff --git a/Analizator9000/Analizator9000/BCalcWrapper.cs b/Analizator9000/Analizator9000/BCalcWrapper.cs
index 9c0a5fa..c9b493e 100644
--- a/Analizator9000/Analizator9000/BCalcWrapper.cs
+++ b/Analizator9000/Analizator9000/BCalcWrapper.cs
@@ -144,7 +144,7 @@ namespace Analizator9000
}
catch (Exception)
{
- throw new Exception("Nie można wczytać rozdania: " + deal);
+ throw new Exception(Form1.GetResourceManager().GetString("BCalcWrapper_dealLoadError") + ": " + deal);
}
this.solver = BCalcWrapper.bcalcDDS_new(Marshal.StringToHGlobalAnsi(BCalcWrapper.table), Marshal.StringToHGlobalAnsi(this.deal), 0, 0);
this.errorCheck();
@@ -158,7 +158,7 @@ namespace Analizator9000
{
if (trumpSuit < 0)
{
- throw new Exception("Nieprawidłowe miano: " + trumpSuit);
+ throw new Exception(Form1.GetResourceManager().GetString("BCalcWrapper_trumpError") + ": " + trumpSuit);
}
BCalcWrapper.bcalcDDS_setTrumpAndReset(solver, trumpSuit);
this.errorCheck();
@@ -175,7 +175,7 @@ namespace Analizator9000
{
if (declarer < 0)
{
- throw new Exception("Nieprawidłowy rozgrywający: " + declarer);
+ throw new Exception(Form1.GetResourceManager().GetString("BCalcWrapper_declarerError") + ": " + declarer);
}
int l = (declarer + 1) % 4;
BCalcWrapper.bcalcDDS_setPlayerOnLeadAndReset(solver, l);
diff --git a/Analizator9000/Analizator9000/DealerParser.cs b/Analizator9000/Analizator9000/DealerParser.cs
index 06adcbc..9d9c61c 100644
--- a/Analizator9000/Analizator9000/DealerParser.cs
+++ b/Analizator9000/Analizator9000/DealerParser.cs
@@ -95,7 +95,7 @@ namespace Analizator9000
case "generate":
if (section.Length > 1)
{
- throw new Exception("Zbyt duża liczba wartości 'generate' w skrypcie");
+ throw new Exception(Form1.GetResourceManager().GetString("DealerParser_errorTooManyGenerate"));
}
if (section.Length == 1)
{
@@ -105,14 +105,14 @@ namespace Analizator9000
}
catch (OverflowException)
{
- throw new Exception("Za duża wartość 'generate'");
+ throw new Exception(Form1.GetResourceManager().GetString("DealerParser_errorGenerateOverflow"));
}
}
break;
case "produce":
if (section.Length > 1)
{
- throw new Exception("Zbyt duża liczba linii 'produce' w skrypcie");
+ throw new Exception(Form1.GetResourceManager().GetString("DealerParser_errorTooManyProduce"));
}
if (section.Length == 1)
{
@@ -122,7 +122,7 @@ namespace Analizator9000
}
catch (OverflowException)
{
- throw new Exception("Za duża wartość 'produce'");
+ throw new Exception(Form1.GetResourceManager().GetString("DealerParser_errorProduceOverflow"));
}
}
break;
diff --git a/Analizator9000/Analizator9000/DealerWrapper.cs b/Analizator9000/Analizator9000/DealerWrapper.cs
index 15db4d2..cc739f2 100644
--- a/Analizator9000/Analizator9000/DealerWrapper.cs
+++ b/Analizator9000/Analizator9000/DealerWrapper.cs
@@ -46,11 +46,11 @@ namespace Analizator9000
{
if (!File.Exists(scriptname))
{
- throw new Exception("Nie znaleziono pliku: " + scriptname);
+ throw new Exception(Form1.GetResourceManager().GetString("DealerWrapper_errorFileNotFound") + ": " + scriptname);
}
if (produce < 1)
{
- throw new Exception("Nieprawidłowa liczba rozdań do wyprodukowania");
+ throw new Exception(Form1.GetResourceManager().GetString("DealerWrapper_errorInvalidDealCount"));
}
this.scriptname = scriptname;
this.debugForm = debugForm;
diff --git a/Analizator9000/Analizator9000/Form1.cs b/Analizator9000/Analizator9000/Form1.cs
index 180d9e5..0d2ae22 100644
--- a/Analizator9000/Analizator9000/Form1.cs
+++ b/Analizator9000/Analizator9000/Form1.cs
@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using System.IO;
+using System.Resources;
namespace Analizator9000
{
@@ -27,6 +28,18 @@ namespace Analizator9000
}
/// <summary>
+ /// Public getter for localization resource manager
+ /// </summary>
+ /// <returns>Component resource manager for Form1</returns>
+ public static ResourceManager GetResourceManager() {
+ if (resManager == null)
+ {
+ resManager = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
+ }
+ return resManager;
+ }
+
+ /// <summary>
/// "Select file" button click, opens file selection dialog for input script.
/// </summary>
/// <param name="sender"></param>
@@ -86,7 +99,9 @@ namespace Analizator9000
}
catch (Exception ex)
{
- MessageBox.Show("Błąd wczytywania pliku: " + ex.Message, "Błąd wczytywania pliku", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(
+ GetResourceManager().GetString("Form1_fileOpenError") + ": " + ex.Message,
+ GetResourceManager().GetString("Form1_fileOpenError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -122,7 +137,7 @@ namespace Analizator9000
}
catch (Exception ex)
{
- MessageBox.Show("Błąd wprowadzania danych: " + ex.Message, "Błąd wprowadzania danych", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(GetResourceManager().GetString("Form1_generateInputError") + ": " + ex.Message, GetResourceManager().GetString("Form1_generateInputError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
generateGroup.Enabled = true;
analyzeGroup.Enabled = true;
}
@@ -134,13 +149,13 @@ namespace Analizator9000
}
catch (FileNotFoundException)
{
- MessageBox.Show("Nie można utworzyć pliku. Sprawdź, czy w katalogu programu istnieje katalog 'files'", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(GetResourceManager().GetString("Form1_generateFileNotFoundError"), GetResourceManager().GetString("Form1_error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
generateGroup.Enabled = true;
analyzeGroup.Enabled = true;
}
catch (Exception ex)
{
- MessageBox.Show("Błąd generatora: " + ex.Message, "Błąd generatora", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(GetResourceManager().GetString("Form1_generateGeneratorError") + ": " + ex.Message, GetResourceManager().GetString("Form1_generateGeneratorError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
generateGroup.Enabled = true;
analyzeGroup.Enabled = true;
}
@@ -166,7 +181,7 @@ namespace Analizator9000
progressBar.Value = 100;
if (filename != null)
{
- this.addStatusLine("Zapisano do pliku: " + filename);
+ this.addStatusLine(GetResourceManager().GetString("Form1_generateFileSaved") + ": " + filename);
}
analyzeFileNameTextBox.Text = Path.GetFullPath(@"files\" + filename);
generateGroup.Enabled = true;
@@ -257,13 +272,13 @@ namespace Analizator9000
this.abortButton.Enabled = true;
this.fullContractTable.Enabled = false;
statusListBox.Items.Clear();
- this.addStatusLine("Otwieram plik: " + analyzeFileNameTextBox.Text);
+ this.addStatusLine(GetResourceManager().GetString("Form1_analyzeOpenFile") + ": " + analyzeFileNameTextBox.Text);
try
{
String[] deals = File.ReadAllLines(analyzeFileNameTextBox.Text);
if (deals.Length == 0)
{
- throw new Exception("Plik nie zawiera żadnych rozdań");
+ throw new Exception(GetResourceManager().GetString("Form1_analyzeNoDealsError"));
}
List<Contract> cons = new List<Contract>();
foreach (int i in Enumerable.Range(1, 5))
@@ -278,7 +293,7 @@ namespace Analizator9000
}
if (cons.Count == 0)
{
- throw new Exception("Nie podano kontraktów");
+ throw new Exception(GetResourceManager().GetString("Form1_analyzeNoContractsError"));
}
// we run either "old" Accumulator or contract analysis with ScoreAccumulator,
// depending on the button of event origin
@@ -289,7 +304,7 @@ namespace Analizator9000
}
catch (Exception ex)
{
- MessageBox.Show("Błąd analizy: " + ex.Message, "Błąd analizy", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(GetResourceManager().GetString("Form1_analyzeError") + ": " + ex.Message, GetResourceManager().GetString("Form1_analyzeError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
this.setProgress(0);
analyzeButton.Enabled = true;
abortButton.Enabled = false;
@@ -622,5 +637,7 @@ namespace Analizator9000
this.contractAnalyzeButton.Enabled = true;
this.abortButton_Click(sender, e);
}
+
+ private static ResourceManager resManager;
}
}
diff --git a/Analizator9000/Analizator9000/Form1.resx b/Analizator9000/Analizator9000/Form1.resx
index eda0d46..6aef0b5 100644
--- a/Analizator9000/Analizator9000/Form1.resx
+++ b/Analizator9000/Analizator9000/Form1.resx
@@ -1135,7 +1135,7 @@
<value>4</value>
</data>
<data name="button2.Location" type="System.Drawing.Point, System.Drawing">
- <value>411, 20</value>
+ <value>353, 18</value>
</data>
<data name="button2.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
@@ -1162,7 +1162,7 @@
<value>7, 20</value>
</data>
<data name="analyzeFileNameTextBox.Size" type="System.Drawing.Size, System.Drawing">
- <value>398, 20</value>
+ <value>340, 20</value>
</data>
<data name="analyzeFileNameTextBox.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@@ -1180,10 +1180,10 @@
<value>1</value>
</data>
<data name="analyzeGroup.Location" type="System.Drawing.Point, System.Drawing">
- <value>514, 12</value>
+ <value>572, 12</value>
</data>
<data name="analyzeGroup.Size" type="System.Drawing.Size, System.Drawing">
- <value>492, 50</value>
+ <value>434, 50</value>
</data>
<data name="analyzeGroup.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@@ -1203,9 +1203,9 @@
<data name="&gt;&gt;analyzeGroup.ZOrder" xml:space="preserve">
<value>3</value>
</data>
- <metadata name="generateFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <data name="generateFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value>
- </metadata>
+ </data>
<data name="progressBar.Location" type="System.Drawing.Point, System.Drawing">
<value>514, 327</value>
</data>
@@ -1251,9 +1251,9 @@
<data name="&gt;&gt;statusListBox.ZOrder" xml:space="preserve">
<value>1</value>
</data>
- <metadata name="analyzeFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <data name="analyzeFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>171, 17</value>
- </metadata>
+ </data>
<data name="resultTextBox.Font" type="System.Drawing.Font, System.Drawing">
<value>Lucida Console, 9pt</value>
</data>
@@ -4434,12 +4434,12 @@
<data name="&gt;&gt;tabControl1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
- <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <data name="$this.Localizable" type="System.Boolean, mscorlib">
<value>True</value>
- </metadata>
- <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ </data>
+ <data name="$this.Locked" type="System.Boolean, mscorlib">
<value>True</value>
- </metadata>
+ </data>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
@@ -10670,4 +10670,85 @@
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
+ <data name="BCalcWrapper_dealLoadError" xml:space="preserve">
+ <value>Nie można wczytać rozdania</value>
+ </data>
+ <data name="BCalcWrapper_declarerError" xml:space="preserve">
+ <value>Nieprawidłowy rozgrywający</value>
+ </data>
+ <data name="BCalcWrapper_trumpError" xml:space="preserve">
+ <value>Nieprawidłowe miano</value>
+ </data>
+ <data name="DealerParser_errorGenerateOverflow" xml:space="preserve">
+ <value>Za duża wartość 'generate'</value>
+ </data>
+ <data name="DealerParser_errorProduceOverflow" xml:space="preserve">
+ <value>Za duża wartość 'produce'</value>
+ </data>
+ <data name="DealerParser_errorTooManyGenerate" xml:space="preserve">
+ <value>Zbyt duża liczba wartości 'generate' w skrypcie</value>
+ </data>
+ <data name="DealerParser_errorTooManyProduce" xml:space="preserve">
+ <value>Zbyt duża liczba linii 'produce' w skrypcie</value>
+ </data>
+ <data name="DealerWrapper_errorFileNotFound" xml:space="preserve">
+ <value>Nie znaleziono pliku</value>
+ </data>
+ <data name="DealerWrapper_errorInvalidDealCount" xml:space="preserve">
+ <value>Nieprawidłowa liczba rozdań do wyprodukowania</value>
+ </data>
+ <data name="Form1_analyzeError" xml:space="preserve">
+ <value>Błąd analizy</value>
+ </data>
+ <data name="Form1_analyzeNoContractsError" xml:space="preserve">
+ <value>Nie podano kontraktów</value>
+ </data>
+ <data name="Form1_analyzeNoDealsError" xml:space="preserve">
+ <value>Plik nie zawiera żadnych rozdań</value>
+ </data>
+ <data name="Form1_analyzeOpenFile" xml:space="preserve">
+ <value>Otwieram plik</value>
+ </data>
+ <data name="Form1_error" xml:space="preserve">
+ <value>Błąd</value>
+ </data>
+ <data name="Form1_fileOpenError" xml:space="preserve">
+ <value>Błąd wczytywania pliku</value>
+ </data>
+ <data name="Form1_generateFileNotFoundError" xml:space="preserve">
+ <value>Nie można utworzyć pliku. Sprawdź, czy w katalogu programu istnieje katalog 'files'</value>
+ </data>
+ <data name="Form1_generateFileSaved" xml:space="preserve">
+ <value>Zapisano do pliku</value>
+ </data>
+ <data name="Form1_generateGeneratorError" xml:space="preserve">
+ <value>Błąd generatora</value>
+ </data>
+ <data name="Form1_generateInputError" xml:space="preserve">
+ <value>Błąd wprowadzania danych</value>
+ </data>
+ <data name="ScoreAccumulator_IMP" xml:space="preserve">
+ <value>IMP</value>
+ </data>
+ <data name="ScoreAccumulator_MP" xml:space="preserve">
+ <value>max</value>
+ </data>
+ <data name="ScoreAccumulator_txtHeader" xml:space="preserve">
+ <value> KONTRAKT LEWY ZAPIS WYGRA? MAX IMP</value>
+ </data>
+ <data name="ScoreAccumulator_vulBoth" xml:space="preserve">
+ <value>obie po</value>
+ </data>
+ <data name="ScoreAccumulator_vulEW" xml:space="preserve">
+ <value>EW po</value>
+ </data>
+ <data name="ScoreAccumulator_vulnerability" xml:space="preserve">
+ <value>Założenia</value>
+ </data>
+ <data name="ScoreAccumulator_vulNone" xml:space="preserve">
+ <value>obie przed</value>
+ </data>
+ <data name="ScoreAccumulator_vulNS" xml:space="preserve">
+ <value>NS po</value>
+ </data>
</root> \ No newline at end of file
diff --git a/Analizator9000/Analizator9000/ScoreAccumulator.cs b/Analizator9000/Analizator9000/ScoreAccumulator.cs
index 236c118..f213d31 100644
--- a/Analizator9000/Analizator9000/ScoreAccumulator.cs
+++ b/Analizator9000/Analizator9000/ScoreAccumulator.cs
@@ -6,11 +6,16 @@ using System.IO;
namespace Analizator9000
{
/// <summary>
- /// Analysis accumulator for scoreing contracts
+ /// Analysis accumulator for scoring contracts
/// </summary>
class ScoreAccumulator : Accumulator
{
- private readonly string[] vulnerabilities = { "obie przed", "obie po", "NS po", "EW po" };
+ private readonly string[] vulnerabilities = {
+ Form1.GetResourceManager().GetString("ScoreAccumulator_vulNone"),
+ Form1.GetResourceManager().GetString("ScoreAccumulator_vulBoth"),
+ Form1.GetResourceManager().GetString("ScoreAccumulator_vulNS"),
+ Form1.GetResourceManager().GetString("ScoreAccumulator_vulEW")
+ };
/// <summary>
/// Vulnerability setting of the analysis
/// </summary>
@@ -99,8 +104,8 @@ namespace Analizator9000
{
StringWriter sw = new StringWriter();
sw.WriteLine();
- sw.WriteLine("Założenia: {0}", this.vulnerabilities[this.vulnerability]);
- sw.WriteLine(" KONTRAKT LEWY ZAPIS WYGRA? MAX IMP ");
+ sw.WriteLine(Form1.GetResourceManager().GetString("ScoreAccumulator_vulnerability") + ": {0}", this.vulnerabilities[this.vulnerability]);
+ sw.WriteLine(Form1.GetResourceManager().GetString("ScoreAccumulator_txtHeader"));
foreach (KeyValuePair<Contract, long> tricks in this.trickSums)
{
sw.WriteLine(" {0,6} (x{1,3}) {2,5:0.00} {3,9:0.00} {6,5:0.00} {4,5:0.00} {5,7:0.00} ",
@@ -181,8 +186,8 @@ namespace Analizator9000
{
this.maxScoreSums[result.Key] += result.Key.Frequency > 0 ? result.Value : 0;
}
- this.logScores(impScores, dealNo, "IMP");
- this.logScores(maxScores, dealNo, "max");
+ this.logScores(impScores, dealNo, Form1.GetResourceManager().GetString("ScoreAccumulator_IMP"));
+ this.logScores(maxScores, dealNo, Form1.GetResourceManager().GetString("ScoreAccumulator_MP"));
this.form.updateContractTable(this.trickSums, this.scoreSums, this.successSums, this.maxScoreSums, this.impScoreSums, this.dealsScored);
}