DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005

    Exclamation Culture. Use two: en-US, fr-FR.


    I am working on a multi-language web site.
    After a lot of searching and reading I was able to define a way to do this.

    However, I need some help to put this on. I am working on ASP.Net/VB.

    I have a few problems which I hope somebody can help me with:
    1. How to set the en-US as the default culture of my entire web site?
    2. How to detect the culture of a visitor browser and overwrite the default?
    If the user has a cookie placed by my web site I will use that one.
    3. How to create a function (can be ran when a button is clicked) which:
    3.1. Sets a new culture.
    3.2. Places a cookie indicating which cookie is used.
    3.3. Refreshes current page and uses the new culture used.
    4. How can I retrieve in a ASPX page which culture is in use.

    I have the plan. The problem is how to this.

    Can someone help me out?

    Thank You Very Much,

  2. #2
    Join Date
    Aug 2004
    Here are answers to a few of your questions:
    1) In web.config, in the system.web section, add or change the globalization tag so that it has a culture, e.g.: <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" />

    2) I don't know if it is possible to set the culture on the session level, but if nothing else you could store the user's culter in the Session state and use it to load different content.

    3.1) Don't know... see #2.

    3.2) Response.Cookies.Add(new HttpCookie("userCulture", culture))

    3.3) Set the session culture using whatever method you find, then Response.Redirect or Server.Transfer back to the same page.

    4) Request.UserLanguages is a sorted array of language preferences set in the browser. Request.UserLanguages(0) is the preferred language.

  3. #3
    Join Date
    Mar 2005
    I also don't know how to set the culture on session level. But it can be done on thread level (each request).


    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Request.UserLanguages[0]);

    to the "Application_BeginRequest" event in Global.asax may do what you want in Q2.

  4. #4
    Join Date
    Aug 2004
    Maybe it would be possible to store the culture in the Session state and retrieve it on each request as oupoi showed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center