W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2013

Re: [whatwg] HTML: A DOM attribute that returns the language of a node

From: Kang-Hao (Kenny) Lu <kanghaol@oupeng.com>
Date: Wed, 24 Apr 2013 11:08:42 +0800
Message-ID: <51774CBA.20400@oupeng.com>
To: Peter Occil <poccil14@gmail.com>
Cc: WHAT Working Group <whatwg@whatwg.org>
(13/04/23 16:44), Peter Occil wrote:
> I believe there should be a DOM attribute that returns the language
> of a node, as defined in section 3.2.3.3 "The lang and xml:lang
> attributes".

What's your use case? If you want to style a particular language then
there's the CSS :lang() pseudo-class.

Use cases are important because otherwise I think there are very few
pages with multiple lang attributes...

> While there is a "lang" DOM attribute, it's inadequate because it's
> only affected by the element's "lang" content attribute.

That's true. However, if the case isn't important, we can do tree
traversal (modulo HTTP Content-Language header and pragma) or exhaust
element.matchesSelector(":lang(xxx)").

> Also, I don't see a way to get the "language of a node" otherwise,
> especially since it depends not only on "lang" and "xml:lang", but
> also on the HTTP Content-Language header, which may not be possible
> to retrieve with existing JavaScript methods, as far as I can tell.

Indeed.


Cheers,
Kenny
-- 
Web Specialist, Opera Sphinx Game Force, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/
Received on Wednesday, 24 April 2013 03:09:17 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:57 UTC