Does anyone have an idea why my code is not working? I get English strings everywhere.
Note that is not an ASP.NET project but an actual WinForms project.
I have set up a windows forms project to use localization so that it will support Arabic and English languages.
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
Admin admin = new Admin();
this.Close();
admin.Show();
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-KW");
Admin admin = new Admin();
this.Close();
admin.Show();
What I have tried:
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
this.Controls.Clear();
this.RightToLeftLayout = false;
InitializeComponent();
Properties.Settings.Default["lang"] = "en-US";
Properties.Settings.Default.Save();
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-KW");
this.Controls.Clear();
InitializeComponent();
Properties.Settings.Default["lang"] = "ar-KW";
Properties.Settings.Default.Save();
and
var ChangLanuguage = new Changelanguage();
ChangLanuguage.Updateconfig("language", "ar-KW");
Application.Restart();
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Admin));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
and
private void metroTile58_Click(object sender, EventArgs e)
{
switch(Thread.CurrentThread.CurrentUICulture.IetfLanguageTag)
{
case "ar-KW":Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");break;
case "en-US": Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-KW"); break;
}
this.Controls.Clear();
InitializeComponent();
}
It works when I test it by starting to debug but when I setup (When the program is extracted) the application it stops working.