In our applications we use something like this to get/set Frontend Language
try { //get language from last user setting... Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(Settings.Default.CultureSelected); }
CurrentCulture will be set from a settings string...
Settings.Default.CultureSelected = newLanguage; //"it-IT"; Settings.Default.Save(); //Manual restart necessary MessageBox.Show(Resources.YouHaveToRestartTheApplicationToAffectTheChangeToTheLanguage, Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);Bad Example - Messagebox that the user should restart application, why not do it by code?
Settings.Default.CultureSelected = newLanguage; //"it-IT"; Settings.Default.Save(); //Restart necessary? yes System.Diagnostics.Process.Start(Application.ExecutablePath); MessageBox.Show(Resources.ApplicationWillBeRestarted, Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Use this since we are a WinForms app System.Windows.Forms.Application.Exit();Good Example - Automatically restart from code
Settings.Default.CultureSelected = newLanguage; //"it-IT";
Settings.Default.Save();
//Restart necessary? yes
System.Diagnostics.Process.Start(Application.ExecutablePath);
MessageBox.Show(Resources.ApplicationWillBeRestarted, Resources.Warning,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
if (MessageBox.Show(Resources.YouMustRestartTheComputerForTheChangesToTakeEffectNLNLRestartNow, Resources.Warning,
MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
//Restart necessary? yes
System.Diagnostics.Process.Start(Application.ExecutablePath);
// Use this since we are a WinForms app
System.Windows.Forms.Application.Exit();
}
Good (even better) Example - Ask user if we should restart now...Thanks to Jury Strumpflohner for his suggestion!
PS
Remember, to start new process and THEN exit... else it want be started
PPS
Remember to set start parameters if you use them
PPPS
If user is in special application area the restart is maybe a bit distracting, cause he's loosing his actual context
- i navigated threw a list of articles
- selected one
- go into modify mode of that article
- then change the language of the application --> Restart?