Culture

  • Thread starter Thread starter JezB
  • Start date Start date
For making culture specific u need to import
Imports System.Globalization
Imports System.Threading

With we get current user culture info.
Request.UserLanguages;

U can set Thread, for UI current culture used by the Resource Manager to
look up culture-specific Thread.
CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Request.UserLanguages(0))

If u want to set specific then u can use. For eg.
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja")

Their r many document to culture is availbale on web.

HTH.

Thanks,

sswalia
 
The problem I am having is that a change of culture is not "sticking". I
provide a poplist of cultures and allow the user to select culture from a
poplist. In the handler for this poplist I set CurrentCulture and
CurrentUICulture, thus :

private void cCulture_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string newCulture = cCulture.SelectedItem.Value;
Thread.CurrentThread.CurrentCulture = new CultureInfo(newCulture);
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture;

Debug.WriteLine("Culture switched to "+newCulture);
testCulture();
// loses culture again here
}

and in testCulture() I write out some dates and numbers to check what
culture is being used. When I change the culture using the poplist I get the
output I expect, but if I invoke testCulture from some other handler, eg. a
button handler, the output is in the default English-US again (when I hit
the button AFTER changing the culture poplist).

What am I missing? HOw can I make the change of culture stick not only
within the context of the Page being run, but all other pages run in the
user's session?
 
Back
Top