HighTechTalks DotNet Forums  

Question about currentCulture class.

Dotnet Internationalization microsoft.public.dotnet.internationalization


Discuss Question about currentCulture class. in the Dotnet Internationalization forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Poonam
 
Posts: n/a

Default Question about currentCulture class. - 02-16-2005 , 04:15 PM






Hi,
I am writing a .NET based web application which is localized also. I am
using Form Authentication and I use following code to transfer to the next
page:

FormsAuthentication.RedirectFromLoginPage(email, false);

Now on Session Start, I have following code:
protected void Session_Start(Object sender, EventArgs e)
{
// For each session request initialize the culture values with the
// user language as specified by url.

try
{
string culture = Request.Params.Get("lang");
if (culture == null)
{
culture = ConfigurationSettings.AppSettings["DefaultLanguage"];
}

try
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture
(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
catch(Exception)
{
// provide fallback for not supported languages. This is really just a
safety catch,
//for 'in-case' scenarios
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
}

So my first page shows me the right content based on the language but as
soon as they are redirected to the next page after authentication, my culture
value is set back to "English US".

I really appreciate if you guys can help me.

Thanks
Poonam

Reply With Quote
  #2  
Old   
JezB
 
Posts: n/a

Default Re: Question about currentCulture class. - 02-25-2005 , 12:35 PM






I think you need to instantiate Culture and UICulture on every request,
rather than every session. You can do it in
Application_PreRequestHandlerExecute or Application_BeginRequest (but the
latter does not have Session available).

"Poonam" <Poonam (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,
I am writing a .NET based web application which is localized also. I am
using Form Authentication and I use following code to transfer to the next
page:

FormsAuthentication.RedirectFromLoginPage(email, false);

Now on Session Start, I have following code:
protected void Session_Start(Object sender, EventArgs e)
{
// For each session request initialize the culture values with the
// user language as specified by url.

try
{
string culture = Request.Params.Get("lang");
if (culture == null)
{
culture = ConfigurationSettings.AppSettings["DefaultLanguage"];
}

try
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture
(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
catch(Exception)
{
// provide fallback for not supported languages. This is really just a
safety catch,
//for 'in-case' scenarios
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
}

So my first page shows me the right content based on the language but as
soon as they are redirected to the next page after authentication, my
culture
value is set back to "English US".

I really appreciate if you guys can help me.

Thanks
Poonam



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.