locked
Culture in Asp.Net 2.0. Need a few tips. RRS feed

  • Question

  • User1608082067 posted
    Hello,

    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
    Friday, September 15, 2006 11:17 AM

Answers

All replies

  • User-1395392389 posted
    1. <globalization culture="it-IT" uiCulture="it-IT" />
       in your system.web zone.
    2. 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:
      1. save them in a cookie
      2. if the user is profiled then save them in your database.
    3. For translating questions I think you'll find plethora of articles and how-to's (but I think this isn't your main problem)
     
     Hope it helps.
    Friday, September 15, 2006 11:47 AM
  • User1608082067 posted

    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
     

    Friday, September 15, 2006 12:43 PM
  • User-1395392389 posted

    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/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 15, 2006 1:52 PM