Localization - override the browser default the FIRST time

Posted on 2006-05-12
Last Modified: 2010-04-16
I have localization setup in a page and it's working great.  I have 4 resx files for the languages I want, and a dropdown list that allows the user to change the language if they so desire.  The default language of the browser is automatically detected and that language is displayed to the user.

However, I don't want this browser detection to take place, or rather, I want to override it.  For each of my users, I have a language ID stored for them in the DB.  When they come to the page, I want to display it in the language setting I have for them in the DB, independent of what their browser default is.  (This is so that a Spanish speaking user in a coffee shop in China will see the page load in Spanish the FIRST time.)

Currently, I can't see any way to do this.  The Spanish user in China would see the page load in Chinese FIRST, and then have to manually change a dropdownlist in order to see it in Spanish.  This kind of makes the language settings I've stored in the DB useless, as they're always overriden by the browser.

The technical problem is that for localization code, you have to override the Page.InitializeCulture() method.  This method happens so early in the page lifecycle that I don't yet know what user is viewing the page (encrypted query string data), and I have no way of setting the language accordingly.

Thanks for your insight.
Question by:tradeline
    1 Comment
    LVL 14

    Accepted Solution

    Have a look at this page. It contains an example how to set Localization information on web pages. I would do this in the Page_Load (You are required to do this in every page!!):

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now