Skip to content

Commit

Permalink
L10N: read config in advance
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiTiSu authored and meee1 committed Sep 16, 2015
1 parent 75daff0 commit 9e0155f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Controls/ConnectionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
using System.Text;
using System.Windows.Forms;
using MissionPlanner.Comms;
using System.Threading;

namespace MissionPlanner.Controls
{
public partial class ConnectionControl : UserControl
{
public ConnectionControl()
{
Thread.CurrentThread.CurrentUICulture = L10N.ConfigLang;
InitializeComponent();
this.linkLabel1.Click += (sender, e) =>
{
Expand Down
14 changes: 11 additions & 3 deletions L10N.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@

namespace MissionPlanner
{
public static class L10N
public class L10N
{
public static CultureInfo ConfigLang = GetConfigLang();
public static CultureInfo ConfigLang;

static L10N()
{
MainV2.xmlconfig(false);
ConfigLang = GetConfigLang();
Strings.Culture = ConfigLang;
//In .NET 4.5,System.Globalization.CultureInfo.DefaultThreadCurrentCulture & DefaultThreadCurrentUICulture is avaiable
}

public static CultureInfo GetConfigLang()
{
Expand All @@ -22,7 +30,7 @@ public static CultureInfo GetConfigLang()
}
else
{
return CultureInfo.GetCultureInfo("en-US");
return System.Globalization.CultureInfo.CurrentUICulture;
}
}

Expand Down
4 changes: 1 addition & 3 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ protected override void OnFormClosed(FormClosedEventArgs e)
}


private void xmlconfig(bool write)
internal static void xmlconfig(bool write)
{
if (write || !File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"config.xml"))
{
Expand Down Expand Up @@ -2556,8 +2556,6 @@ public void changelanguage(CultureInfo ci)
config["language"] = ci.Name;
//System.Threading.Thread.CurrentThread.CurrentCulture = ci;

L10N.ConfigLang = ci;

HashSet<Control> views = new HashSet<Control> { this, FlightData, FlightPlanner, Simulation };

foreach (Control view in MyView.Controls)
Expand Down

0 comments on commit 9e0155f

Please sign in to comment.