[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Localization - override the browser default the FIRST time

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.
sk
0
tradeline
Asked:
tradeline
1 Solution
 
existenz2Commented:
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!!):
http://www.dotnetjunkies.com/Tutorial/17E26271-E212-4248-965F-4B33D2EDD38B.dcik
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now