Automatic language-culture selection and fallback algorithm in ASP.NET

t3hp1t

New Member
We are building a site that supports several languages. We have created resources to support fr, de, and en-US with en-US as the default. I have added:\[code\]<system.web> <globalization uiCulture="auto" culture="auto" requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="true" /> ...</system.web>\[/code\]to my \[code\]web.config\[/code\] file. If I set the language to fr, de, or en-US in IE or Chrome, I get the expected language. If I set the language to ar-EG, I get en-US, also as expected.If I set my language to fr-FR, but do not include fr in the list of accepted languages, the site returns the fr page, even if I tell the browser that I prefer accept de to generalized fr (as opposed to fr-FR). This appears to be contrary to the RFC's, but is not surprising, because IE defaults to fr-FR in France and de-DE in Germany, and does not work with sites that do not automatically generalize the culture.However, if I tell the browser that I accept ar-EG and fr, the site defaults to en-US -- even though the Accept-Language header specifies that I will accept fr with a higher priority. I captured the request header in the browser to make sure all the languages I asked for were being sent with the right priorities.It appears that ASP.NET is only ever looking at the first language specified in the Accept-Language header. Is the ASP.NET language matching algorithm specified anywhere? Is there a way to specify that ASP.NET/MVC should check all the languages in the Accept-Language list to determine the best one? Or do I have to write my own language matching code?
 
Back
Top