Last post Aug 18, 2006 05:35 AM by rogerw
Aug 17, 2006 03:19 AM|arco|LINK
I've got stuck:
I'm trying to make simple localizable site, but the point it's user who selects the language. Application shouldn't make any decisions depending on browser settings.
All examples I've seen on MSDN or elsewhere use the auto mode of UICulture or just tell about the basics of localization system.
I use local resources to store the translations. The task is: when a user presses some LinkButton, site should change its language.
My solution was: on PageLoad (or on Init, tried both), depending on request parameters, set Session["lang"] = "en" (or other language I'm using). Then, I use this line (same here, tried both in Load and Init event handlers):
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo((string)Session["lang"]);
This works, debugger shows, that everything goes where it should go. I even set the text of one label to CurrentUICulture and that works too, but...
I don't see any change of language. Please help!
PS. I use MasterPage to build this site, but neither masterpage nor child pages render with the desired language.
Aug 17, 2006 04:27 PM|vivek_iit|LINK
Did you try changing the language settings in the Control Panel's Region and Language settings section?
You have changed the culture of the current thread, but you need to change the OS settings too to display the UI settings in appropriate language.
Aug 18, 2006 03:21 AM|arco|LINK
No, the thing is that I do NOT want to automatically choose language. User must select desired language.
And I found the solution yesterday, I just need to override the InitializeCulture() method of a page and write there culture initialization :)
Now, I need to know how to intercept event from some asp:LinkButton before InitializeCulture() runs.
Any ideas on how to do that?
Thanx 4 help
Aug 18, 2006 05:35 AM|rogerw|LINK
My solution is to use
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(tMyLang)Thread.CurrentThread.CurrentUICulture =
in the Page_Init or the "Application_PreRequestHandlerExecute" of the Global.asax.
The "tMyLang" is assigned fex. from 1)page-querystring, or 2)session-variabel, or 3)Cookie.