I'm working on one application to which i would like to support localization. i have implemented the Satellite assembly concept to implement the Localization but the problem is it will load/render the text of all controls at runtime based on the chosen language which makes my application loading very slow.
now my question is : is there any better approach through which i can update all of my Main Form controls without delay/flickering while loading time.
I'm developing the application using c#.net Winforms.
My Project structure:
here is what i have tried [sample code]:
Note : this works fine because this sample application only contains the very few controls but my actual application contains too many controls which definatly will delay/flicker while loading.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;
namespace Localization
{
public partial class Form1 : Form
{
#region constants
const String DEFAULT_CULTURE = "en-US";
#endregion
ResourceManager resourceManager = null;
public Form1()
{
InitializeComponent();
resourceManager = new ResourceManager("Localization.Resources", Assembly.GetExecutingAssembly());
}
private void cmbSelectLanguages_SelectedIndexChanged(object sender, EventArgs e)
{
String languageCode = "";
switch (cmbSelectLanguages.SelectedItem.ToString())
{
case "German": languageCode = "de-DE";
break;
case "French": languageCode = "fr-FR";
break;
case "English": languageCode = DEFAULT_CULTURE;
break;
default: languageCode = DEFAULT_CULTURE;
break;
}
SetCulture(languageCode);
SetControlsText();
}
private void SetCulture(String languageCode)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(languageCode);
}
private void Form1_Load(object sender, EventArgs e)
{
//set the default languge to US-English while loading the form
SetCulture(DEFAULT_CULTURE);
SetControlsText();
}
private void SetControlsText()
{
lblCulture.Text = " " + System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
lblUserName.Text = resourceManager.GetString("lblUsername");
lblPassword.Text = resourceManager.GetString("lblPassword");
btnLogin.Text = resourceManager.GetString("lblLogin");
btnCancel.Text = resourceManager.GetString("lblCancel");
lblChooseLanguage.Text = resourceManager.GetString("lblChooseLanguage");
lblLoginTitle.Text = resourceManager.GetString("lblUserLogin");
pic.Image = (Image)resourceManager.GetObject("Login");
}
private void btnCancel_Click(object sender, EventArgs e)
{
}
private void btnLogin_Click(object sender, EventArgs e)
{
}
}
}