I am working on a multilanguage Asp.Net 2.0 web site.
I need to do the following:
1. Set a default culture in Web.Config File.
2. Create a function which changes culture when pressed.
Remember the choosen culture next time the visitor comes to the web site.
3. Retrieve the current culture.
<globalization culture="it-IT" uiCulture="it-IT" />
in your system.web zone.
I would suggest a base-page-class (to be inherited by every page in you app) where an overridden version of subroutine InitializeCulture has to be put. There you'll code the logic to retrieve and set the appropriate culture.
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("de-DE");
To preserve infos about user preferences you can:
save them in a cookie
if the user is profiled then save them in your database.
For translating questions I think you'll find plethora of articles and how-to's (but I think this isn't your main problem)
Member
429 Points
3843 Posts
Culture in Asp.Net 2.0. Need a few tips.
Sep 15, 2006 11:17 AM|shapper|LINK
I am working on a multilanguage Asp.Net 2.0 web site.
I need to do the following:
1. Set a default culture in Web.Config File.
2. Create a function which changes culture when pressed.
Remember the choosen culture next time the visitor comes to the web site.
3. Retrieve the current culture.
How can I do this?
Thanks,
Miguel
Member
63 Points
80 Posts
Re: Culture in Asp.Net 2.0. Need a few tips.
Sep 15, 2006 11:47 AM|Ryoushin|LINK
Member
429 Points
3843 Posts
Re: Culture in Asp.Net 2.0. Need a few tips.
Sep 15, 2006 12:43 PM|shapper|LINK
Hello,
1. When I set the culture in web.config globalization doesn't that mean that it everytime he visits the web site he will have those values.
2. I created this profile:
<anonymousIdentification enabled="true" />
<profile>
<properties>
<add name="UserCulture" defaultValue="en-US" />
<add name="UserUICulture" defaultValue="en"/>
</properties>
</profile>
Then I just set the profile property UserCulture or UserUICulture.
It will be saved, right?
3. This one I got it.
Thanks,
Miguel
Member
63 Points
80 Posts
Re: Culture in Asp.Net 2.0. Need a few tips.
Sep 15, 2006 01:52 PM|Ryoushin|LINK
Ok. Now I better understand your scenario...
<add name="UserCulture" defaultValue="en-US" allowAnonymous="true" />
...
have you read this msdn magazine article? maybe it matches your needs:
http://msdn.microsoft.com/msdnmag/issues/06/08/BasicInstincts/