I have a website with a page called buystuff.aspx. I've created two local resources: buystuff.aspx.resx and buystuff.aspx.da-dk.resx.
This works fine, and if I enter the site with a da-DK setting, I get that version, and if I enter with anything else, I get the default.
However, what i want, is to set this programmatically. When the user enters buystuff.aspx they should be forced into the english (en-US) version, and if they enter buystuff.aspx?language=da, they should be forced into the da-dk one.
The following code doesn't do the trick:
private void SetupLanguage()
{
if (!string.IsNullOrEmpty(CurrentLanguage))
{
if (CurrentLanguage == "da")
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK");
return;
}
}
Culture = "en-US";
UICulture = "en-US";
}
I have also tried the following which didn't work:
private void SetupLanguage()
{
if (!string.IsNullOrEmpty(CurrentLanguage))
{
if (CurrentLanguage == "da")
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK");
return;
}
}
CultureInfo info = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentUICulture = info;
Thread.CurrentThread.CurrentCulture = info;
}
In the debug mode, I can tell the code is run as it should. However, when loading buybtc.aspx (and my CurrentLanguage variable is string.empty), it still loads resources from buystuff.aspx.da-dk.resx.
Any ideas?