Re: Detecting inherited language

Sorry, I only just realised that these messages were going into a 
separate mail folder. :(

I'm trying to test whether a language declaration (lang attribute, meta 
element, or http) is actually setting the language lower down the 
element tree in a recognisable way.  That's why recursing and such is 
not really relevant.

In the end, I found that :lang is supported by all major browsers now, 
so I use that to detect whether the language is set as expected. The 
tests have a mechanism included that checks whether :lang is supported 
and if it isn't tells you and sets the result to fail.) (I wish the test 
framework js would allow you to say 'Don't know' rather than just pass 
or fail, btw.)

(You can see the completed tests at 
http://www.w3.org/International/tests/html5/the-lang-attribute/results-lang 
if you're interested.)

Pity it's not exposed in the DOM - that would make it *much* easier to 
take bits out of a file and pick up the language information.

Thanks,
RI


On 10/07/2013 10:04, Robin Berjon wrote:
> On 10/07/2013 10:47 , Tobie Langel wrote:
>> On Wednesday, July 10, 2013 at 10:38 AM, Richard Ishida wrote:
>>> Can anyone tell me whether there's a way to detect the inherited
>>> language of an element, other than by recursing up the tree looking
>>> for lang attributes? (I'm looking for something like
>>> computedvalue.)
>>
>> What's wrong with the recursive approach? You can always wrap it up
>> in a little helper/assertion function.
>
> You need more than to recurse, you also need to look at the <meta> and
> at the end you need to XHR your own location and look at
> Content-Language. It's all doable, but a bit cumbersome.
>
> And Richard, I forget when this came up, but the conclusion last time
> around was that this information was unfortunately not exposed in the
> DOM so you indeed have to get it yourself.
>


-- 
Richard Ishida, W3C
http://rishida.net/

Received on Monday, 15 July 2013 18:53:06 UTC