What is use for request/language

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
Hi everybody:

I have been attempting to improve the issues.roundup-tracker.org
scores.  One of the things is reports is that the head tag is missing
a lang attribute. So the page has no indication of the language.

Ok easy enough, add a tal:attributes="lang request/language". However
request/language can be a list, so I ended up with:

  lang="['en_US', 'en']"

not exactly what I was expecting (nor is it valid). It looks like
en_US would need to be en-US (language-region) format to be
valid. 'en' is fine. But an list isn't allowed.

Using:

  tal:attributes="lang python:request.language[-1]"

does generate

  lang="en"

as wanted, but can I guarentee the proper 2 character language subtag
(per BCP47) will be the last in the list? Looking at the headers
sent by the browser:

  Accept-Language: en-US,en;q=0.9

I guess this just happens to work. Appending "?@language=de-DE"
results in request/language beign set to "de-DE" as
expected. Unsetting the languag cookie using "?@language=none" results in

 <head lang>

but I consider this to be an edge case and it is handled properly by
browsers so I am not going to fix it.

Is there a better request variable to use for setting this attribute?
Does anybody have a templating extension for setting the lang attribute?

I would like to add this to all the page templates that we distribute.

Thanks.

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.