Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good day

How to create a multilingual windows form that can change the display language of open dialog box?I have a form application and would like the user to change the language of display. Here is my code, so far I can change the form controls including the menu item, I couldn't change the show dialog boxes button texts (ok, cancel, abort...) so I decide to create my own normal window form to act as a dialog box, and it's working fine.
I selected the Localizable property of the form to True and created a language resource file (resx) for each language. It working fine even if I have to restart the application for the language to take effect, I don't have a problem with that though.
The problem is how to change the open dialog box, because I couldn't create a custom one. Let say I want an open dialog box where a user can browse and open an image, it still display in English (File name, Open and Cancel Button...)

Here is my code:

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Net.NetworkInformation;

namespace Language
{
public partial class Form1 : Form
{
public string language = Properties.Settings.Default.Langue;

public Form1()
{

Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
InitializeComponent();
}

private void englishMenuItem_Click(object sender, EventArgs e)
{

language = "en";
englishMenuItem.Checked = true;
germanMenuItem.Checked = false;
frenchMenuItem.Checked = false;

// Save user choice in settings
Properties.Settings.Default.Langue = "en";
Properties.Settings.Default.Save();
}


private void frenchMenuItem_Click(object sender, EventArgs e)
{
// ChangeLanguage("fr-FR");
language = "fr-FR";
frenchMenuItem.Checked = true;
germanMenuItem.Checked = false;
englishMenuItem.Checked = false;



// Save user choice in settings
Properties.Settings.Default.Langue = "fr-FR";
Properties.Settings.Default.Save();
}



Thank you very much
Posted

Nearly all the main ideas you will need to know are covered in my past answers on the topic:
How to use a Single resx file for 3 languages[^],
globalization in winforms[^],
globalization/localization problem in winform .net[^].

And also this one: Globalization of Checkboxes[^].

The display language can be switched during runtime by changing the culture and UI culture of the current UI thread and invalidation/refreshing the view. The required satellite assemblies would be picked up and loaded, from the choices you provided, automatically; in case of missing required satellite assembly the fallback mechanism will be automatically used. This is the whole idea of those satellite assemblies and localization/globalization based on them.

See also:
http://msdn.microsoft.com/en-us/library/9xdxwwkc%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/y99d1cd3%28v=vs.110%29.aspx[^].

Good luck.
—SA
 
Share this answer
 
Thank you for your message, but i am still struggling, I am not an expect in C#, could you provide me with just a simple code example on how to do this?
Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900