Skip to content

Commit 30b0ecb

Browse files
committed
[*]Added French
[*]Added Serbian [*]Added Korean [*]Improved LanguageManager performance [*]Fixed an issue when using a custom language with no language file set.
1 parent 719986d commit 30b0ecb

File tree

17 files changed

+447
-68
lines changed

17 files changed

+447
-68
lines changed

DeadLock/Classes/Language.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Language
1515
public string BtnClose;
1616
public string BarItemSettings;
1717
public string BarItemAbout;
18+
public string BtnLicense;
1819
#endregion
1920

2021
#region Main_Form
@@ -53,7 +54,6 @@ public class Language
5354
public string BarItemHelp;
5455
public string BarItemCheckForUpdates;
5556
public string BarItemHomePage;
56-
public string BarItemLicense;
5757

5858
//Main Form - ListView Items:
5959
public string ClhPath;
@@ -114,9 +114,6 @@ public class Language
114114
public string TxtAboutTheme;
115115
public string TxtAboutCopyright;
116116
public string TxtAboutTranslation;
117-
118-
//About Form - Button:
119-
public string BtnLicense;
120117
#endregion
121118

122119
#region Settings_Form

DeadLock/Classes/LanguageManager.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ internal void LoadLanguage(string path)
3434
}
3535

3636
/// <summary>
37-
/// Load a Language using the project resources, depending on the settings.
37+
/// Load a language using the Resources, depending on the index.
3838
/// </summary>
39-
internal void LoadLanguage()
39+
/// <param name="index">The index of the language that should be loaded.</param>
40+
internal void LoadLanguage(int index)
4041
{
4142
XmlSerializer serializer = new XmlSerializer(_currentLanguage.GetType());
4243
using (MemoryStream stream = new MemoryStream())
4344
{
4445
StreamWriter writer = new StreamWriter(stream);
4546
string res;
46-
switch (Properties.Settings.Default.Language)
47+
switch (index)
4748
{
4849
case 0:
4950
res = Properties.Resources.nl;
@@ -52,12 +53,21 @@ internal void LoadLanguage()
5253
res = Properties.Resources.eng;
5354
break;
5455
case 2:
55-
res = Properties.Resources.ita;
56+
res = Properties.Resources.fr;
5657
break;
5758
case 3:
58-
res = Properties.Resources.pl;
59+
res = Properties.Resources.ita;
5960
break;
6061
case 4:
62+
res = Properties.Resources.kor;
63+
break;
64+
case 5:
65+
res = Properties.Resources.pl;
66+
break;
67+
case 6:
68+
res = Properties.Resources.sr;
69+
break;
70+
case 7:
6171
res = Properties.Resources.tr;
6272
break;
6373
default:

DeadLock/DeadLock.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
</ItemGroup>
184184
<ItemGroup>
185185
<Content Include="Paomedia-Small-N-Flat-Lock.ico" />
186+
<None Include="Resources\Languages\kor.xml" />
187+
<None Include="Resources\Languages\sr.xml" />
188+
<None Include="Resources\Languages\fr.xml" />
186189
<None Include="Resources\Languages\tr.xml" />
187190
<None Include="Resources\Languages\nl.xml" />
188191
<None Include="Resources\Languages\pl.xml" />

DeadLock/Forms/FrmMain.cs

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ public FrmMain(string[] args)
4444
{
4545
_languageManager = new LanguageManager();
4646
_update = new Update();
47-
if (Properties.Settings.Default.Language == 5)
47+
if (Properties.Settings.Default.Language == 8)
4848
{
49-
_languageManager.LoadLanguage(Properties.Settings.Default.LanguagePath);
49+
if (Properties.Settings.Default.LanguagePath.Length != 0)
50+
{
51+
_languageManager.LoadLanguage(Properties.Settings.Default.LanguagePath);
52+
}
53+
else
54+
{
55+
_languageManager.LoadLanguage(1);
56+
}
5057
}
5158
else
5259
{
53-
_languageManager.LoadLanguage();
60+
_languageManager.LoadLanguage(Properties.Settings.Default.Language);
5461
}
5562
LanguageSwitch();
5663
}
@@ -106,7 +113,7 @@ private void LanguageSwitch()
106113
helpBarItem.Text = l.BarItemHelp;
107114
checkForUpdatesBarItem.Text = l.BarItemCheckForUpdates;
108115
homePageBarItem.Text = l.BarItemHomePage;
109-
licenseBarItem.Text = l.BarItemLicense;
116+
licenseBarItem.Text = l.BtnLicense;
110117
aboutBarItem.Text = l.BarItemAbout;
111118

112119
//Main Form - ListView Items:
@@ -159,47 +166,46 @@ private void LanguageSwitch()
159166
private async void Update(bool showError, bool showNoUpdates)
160167
{
161168
Language l = _languageManager.GetLanguage();
162-
163-
try
169+
await Task.Run(() =>
164170
{
165-
WebClient wc = new WebClient();
166-
string xml = await wc.DownloadStringTaskAsync("http://codedead.com/Software/DeadLock/update.xml");
167-
168-
XmlSerializer serializer = new XmlSerializer(_update.GetType());
169-
using (MemoryStream stream = new MemoryStream())
170-
{
171-
StreamWriter writer = new StreamWriter(stream);
172-
writer.Write(xml);
173-
writer.Flush();
174-
stream.Position = 0;
175-
_update = (Update)serializer.Deserialize(stream);
176-
writer.Dispose();
177-
}
178-
if (_update.CheckForUpdate())
171+
try
179172
{
180-
if (MessageBoxAdv.Show(l.MsgVersion + " " + _update.GetUpdateVersion() + " " + l.MsgAvailable + Environment.NewLine + l.MsgDownloadNewVersion, "DeadLock", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
173+
WebClient wc = new WebClient();
174+
string xml = wc.DownloadString("http://codedead.com/Software/DeadLock/update.xml");
175+
176+
XmlSerializer serializer = new XmlSerializer(_update.GetType());
177+
using (MemoryStream stream = new MemoryStream())
178+
{
179+
StreamWriter writer = new StreamWriter(stream);
180+
writer.Write(xml);
181+
writer.Flush();
182+
stream.Position = 0;
183+
_update = (Update)serializer.Deserialize(stream);
184+
writer.Dispose();
185+
}
186+
if (_update.CheckForUpdate())
181187
{
182-
await Task.Run(() =>
188+
if (MessageBoxAdv.Show(l.MsgVersion + " " + _update.GetUpdateVersion() + " " + l.MsgAvailable + Environment.NewLine + l.MsgDownloadNewVersion, "DeadLock", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
183189
{
184190
new FrmUpdater(_update, _languageManager.GetLanguage()).ShowDialog();
185-
});
191+
}
186192
}
187-
}
188-
else
189-
{
190-
if (showNoUpdates)
193+
else
191194
{
192-
MessageBoxAdv.Show(l.MsgLatestVersionAlreadyInstalled, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Information);
195+
if (showNoUpdates)
196+
{
197+
MessageBoxAdv.Show(l.MsgLatestVersionAlreadyInstalled, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Information);
198+
}
193199
}
194200
}
195-
}
196-
catch (Exception ex)
197-
{
198-
if (showError)
201+
catch (Exception ex)
199202
{
200-
MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
203+
if (showError)
204+
{
205+
MessageBoxAdv.Show(ex.Message, "DeadLock", MessageBoxButtons.OK, MessageBoxIcon.Error);
206+
}
201207
}
202-
}
208+
});
203209
}
204210

205211
/// <summary>

DeadLock/Forms/FrmSettings.Designer.cs

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DeadLock/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.3.1.1")]
35-
[assembly: AssemblyFileVersion("1.3.1.1")]
34+
[assembly: AssemblyVersion("1.3.2.0")]
35+
[assembly: AssemblyFileVersion("1.3.2.0")]

DeadLock/Properties/Resources.Designer.cs

Lines changed: 71 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DeadLock/Properties/Resources.resx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@
169169
<data name="website" type="System.Resources.ResXFileRef, System.Windows.Forms">
170170
<value>..\Resources\Images\website.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
171171
</data>
172-
<data name="_lock" type="System.Resources.ResXFileRef, System.Windows.Forms">
173-
<value>..\Resources\Images\lock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
174-
</data>
175172
<data name="autosize" type="System.Resources.ResXFileRef, System.Windows.Forms">
176173
<value>..\Resources\Images\autosize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
177174
</data>
@@ -199,4 +196,16 @@
199196
<data name="tr" type="System.Resources.ResXFileRef, System.Windows.Forms">
200197
<value>..\Resources\Languages\tr.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
201198
</data>
199+
<data name="fr" type="System.Resources.ResXFileRef, System.Windows.Forms">
200+
<value>..\Resources\Languages\fr.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
201+
</data>
202+
<data name="sr" type="System.Resources.ResXFileRef, System.Windows.Forms">
203+
<value>..\Resources\Languages\sr.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
204+
</data>
205+
<data name="kor" type="System.Resources.ResXFileRef, System.Windows.Forms">
206+
<value>..\Resources\Languages\kor.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
207+
</data>
208+
<data name="_lock" type="System.Resources.ResXFileRef, System.Windows.Forms">
209+
<value>..\Resources\Images\lock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
210+
</data>
202211
</root>

DeadLock/Resources/Languages/eng.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<BarItemHelp>Help</BarItemHelp>
2828
<BarItemCheckForUpdates>Check for updates</BarItemCheckForUpdates>
2929
<BarItemHomePage>Homepage</BarItemHomePage>
30-
<BarItemLicense>License</BarItemLicense>
3130
<BarItemAbout>About</BarItemAbout>
3231
<ClhPath>Path</ClhPath>
3332
<ClhStatus>Status</ClhStatus>

0 commit comments

Comments
 (0)