ServerVariables & Language Preferences Support

C

clintonG

I'm messing around with the Request.UserLanguages and the
Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"); to see
how similar or dissimilar they may be.

I observe and conclude that both get their value from the Accept-Language
key stored in the header of the response. To test this hypothesis I
reconfigure IE Language Preferences which by default (for me)
is English (United States)[en-us].

I include a Spanish (Mexico)[es-mx] Language Preference and
use the Language Preferences tool to move the Spanish selection
to the top of the Language Preferences list.

I load a page with a couple of Response.Write statements and see the
following written to the page...

HTTP_ACCEPT_LANGUAGE: es-mx,en-us;q=0.5
User Language 0: es-mx
User Language 1: en-us;q=0.5

So, I ask myself what the heck is this q=0.5 name=value pair?

I go back to Language Preferences and feel like a freedom fighter
so I add Arabic(Iraq)[ar-iq] and this is what is written to the page...

HTTP_ACCEPT_LANGUAGE: es-mx,en-us;q=0.7,ar-iq;q=0.3
User Language 0: es-mx
User Language 1: en-us;q=0.7
User Language 2: ar-iq;q=0.3

So, now I'm asking, "what the heck does this q sh!t mean and why the
inconsistent values?"

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
K

Ken Cox [Microsoft MVP]

Interesting. Here's what my version of IE is sending:

HTTP_ACCEPT_LANGUAGE:en-us,en-ca;q=0.7,fr-ca;q=0.3

Is it inconsistent? Anyway, I'll ask around to see what the q stuff is all
about.

Ken
 
K

Ken Cox [Microsoft MVP]

Here's the explanation that I got from a fellow MVP regarding the "q" part:

Quality - indicates a level of your preference for a particular choice.
A number between 0.0 and 1.0, 0.0 being "never want to use this". If the
server has content in multiple languages that your Accept-Language
header also lists, the server should choose the one with the highest q
number. See RFC2616 for more details:

http://www.faqs.org/rfcs/rfc2616.html
 
C

clintonG

Thanks Ken. Convey my appreciation to your colleague. I'll get around
to reading the RFC. Meanwhile, we know by 'general consensus' that
the language preference settings sent by the user agent are not supposed
to be reliable indicators that can be used to modify page output
(server settings over-ride the user agent) but the server-centric point of
view fails to account for the user's preferences should he or she want to
read content in pages a site operator chose to make available in
different languages regardless.

Preparing to achieve the MCAD cert I've seen two 'correct' answers
regarding how to determine preferences. The first advocates using a
DropDownList to allow the user to select their preference (Kalani,
QUE 70-315). The second advocates getting the preferences from
the request object (Transcender).

Besides thinking through my own design and implementation for a
project I am working on I'm conflicted regarding how to approach
70-315 with two opposing 'correct' answers proferred by two seemingly
equal authoritative sources.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/




Ken Cox said:
Here's the explanation that I got from a fellow MVP regarding the "q" part:

Quality - indicates a level of your preference for a particular choice.
A number between 0.0 and 1.0, 0.0 being "never want to use this". If the
server has content in multiple languages that your Accept-Language
header also lists, the server should choose the one with the highest q
number. See RFC2616 for more details:

http://www.faqs.org/rfcs/rfc2616.html


clintonG said:
I'm messing around with the Request.UserLanguages and the
Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"); to see
how similar or dissimilar they may be.

I observe and conclude that both get their value from the Accept-Language
key stored in the header of the response. To test this hypothesis I
reconfigure IE Language Preferences which by default (for me)
is English (United States)[en-us].

I include a Spanish (Mexico)[es-mx] Language Preference and
use the Language Preferences tool to move the Spanish selection
to the top of the Language Preferences list.

I load a page with a couple of Response.Write statements and see the
following written to the page...

HTTP_ACCEPT_LANGUAGE: es-mx,en-us;q=0.5
User Language 0: es-mx
User Language 1: en-us;q=0.5

So, I ask myself what the heck is this q=0.5 name=value pair?

I go back to Language Preferences and feel like a freedom fighter
so I add Arabic(Iraq)[ar-iq] and this is what is written to the page...

HTTP_ACCEPT_LANGUAGE: es-mx,en-us;q=0.7,ar-iq;q=0.3
User Language 0: es-mx
User Language 1: en-us;q=0.7
User Language 2: ar-iq;q=0.3

So, now I'm asking, "what the heck does this q sh!t mean and why the
inconsistent values?"

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top