if you only care about dutch then just make all the resource strings in
dutch instead of english
since resx files are loaded based on the regional settings of the
device (but I don't mean the language of the device, I mean just the
regional settings screen) you can always manually load them based on a
user defined selection like this
I created 2 resx files in my project, one called strings.resx and the
other strings.nl.resx
in the strings.resx file there is a resource titled "title" and it's
value is "default"
in the strings.nl.resx file there is a resource titled "title" and it's
value is "dutch"
I then created 4 buttons, one to load english, generic dutch, belgian
dutch and german resources
I intentionally did not create a german resource set because I wanted
to show how the lack of a DE resource file causes it to cascade down
and use just the strings.resx set. The same goes for the EN resource
set, it will cascade and use strings.resx and the lack of a nl-BE resx
file will cause the selection of nl-BE to cascade down and use the
generic NL resx
so clicking each of the buttons below lets me change which resource set
is loaded into my global static resource set variable and the result is
that english and german users would see a form title of "default" and
people selecting dutch would see "dutch" as the form title
private void buttonEnglish_Click(object sender, EventArgs e)
{
this.SetLocalizedTitle(new
System.Globalization.CultureInfo("en"));
}
private void buttonGenericDutch_Click(object sender, EventArgs
e)
{
this.SetLocalizedTitle(new
System.Globalization.CultureInfo("nl"));
}
private void buttonBelgianDutch_Click(object sender, EventArgs
e)
{
this.SetLocalizedTitle(new
System.Globalization.CultureInfo("nl-BE"));
}
private void buttonGerman_Click(object sender, EventArgs e)
{
this.SetLocalizedTitle(new
System.Globalization.CultureInfo("de"));
}
private void SetLocalizedTitle(System.Globalization.CultureInfo
culture)
{
try
{
System.Resources.ResourceManager rm = new
System.Resources.ResourceManager("LocalizationTestApp.strings",
System.Reflection.Assembly.GetExecutingAssembly());
//I save the resource set to a static global variable
so other forms and code can access it
//the last 2 "true" parameters important, they allow
the cascade effect to happen to allow nl-BE to default to generic nl
Program.ResourceSet = rm.GetResourceSet(culture, true,
true);
//get the title resource value
this.Text = Program.ResourceSet.GetString("title");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Now using this means you would need to place code in your application
to update all labels and other items with the new resource strings
based on whatever resource set you just loaded dynamically
I hope this makes sense
Jeremy