ASP.NET has build-in functionality to automatically load the correct language resource file based on the browser’s preferred language.
For example, if a visitor has Danish (da) as his/her preferred language, and the website has a *.da.resx file, then that resource is used. When the preferred resource file is not available, ASP.NET falls back to the basic/default resource file (*.resx).
Now, browsers allow for more than one preferred languages to be specified. If the visitor would speak Danish, but added Norwegian as a second language to the browsers preferences (written Norwegian is 95% identical to Danish), then the browser would send “da,no;q=0.9” to the web server. However, it seems this secondary language is not supported by ASP.NET; *.no.resx will not be loaded if *.da.resx is not available.
Does anybody know how to support secondary languages?
Note that ASP.NET only automatically processes the first entry in the accept-languages header field to determine which culture to use if
enableClientBasedCultureis enabled in the web.config file.If you wish to extend this and examine other language entries (if any) in the accept-languages list to see if you have a match, you will have to do it programmatically and set the
Thread.CurrentThread.CurrentUICulture(which the ResourceManager uses to find the appropriate localized resources) andThread.CurrentThread.CurrentCulture(which will control how locale-aware datatypes will be presented and processed). This is explained here.