Download & Extend

Drupal 8 HTML 5 page template should use lang not xml:lang

Project:Drupal core
Version:8.x-dev
Component:theme system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:D8MI, html5, language-base

Issue Summary

The HTML5 template introduced in #1077566: Convert html.tpl.php to HTML5 uses xml:lang in the template, even though the HTML 5 spec has this to say about that:
From http://www.whatwg.org/specs/web-apps/current-work/#the-lang-and-xml:lang...

The lang attribute (in no namespace) specifies the primary language for the element's contents and for any of the element's attributes that contain text. Its value must be a valid BCP 47 language tag, or the empty string. Setting the attribute to the empty string indicates that the primary language is unknown. [BCP47]

The lang attribute in the XML namespace is defined in XML. [XML]

If these attributes are omitted from an element, then the language of this element is the same as the language of its parent element, if any.

The lang attribute in no namespace may be used on any HTML element.

The lang attribute in the XML namespace may be used on HTML elements in XML documents, as well as elements in other namespaces if the relevant specifications allow it (in particular, MathML and SVG allow lang attributes in the XML namespace to be specified on their elements). If both the lang attribute in no namespace and the lang attribute in the XML namespace are specified on the same element, they must have exactly the same value when compared in an ASCII case-insensitive manner.

Authors must not use the lang attribute in the XML namespace on HTML elements in HTML documents. To ease migration to and from XHTML, authors may specify an attribute in no namespace with no prefix and with the literal localname "xml:lang" on HTML elements in HTML documents, but such attributes must only be specified if a lang attribute in no namespace is also specified, and both attributes must have the same value when compared in an ASCII case-insensitive manner.

The attribute in no namespace with no prefix and with the literal localname "xml:lang" has no effect on language processing.

Comments

#1

Also xml:lang is referenced in rdf.module, book module, openid, search, various maintenance templates (which were not yet converted to HTML 5?). At least those things that build data for regular page output like rdf, book, search should use lang AFAIS.

#2

Yep, xml-lang needs be replaced with lang.

#3

Lets see what breaks where.

AttachmentSizeStatusTest resultOperations
1330922.patch1.35 KBIdlePASSED: [[SimpleTest]]: [MySQL] 33,804 pass(es).View details

#4

Status:active» needs review

converted rdf and search modules to @lang. I haven't included the module which output their doctype themselves, as it might have some impact which should be considered in their respective issues: book, openid, and maintenance-page.tpl.php for system, bartik and seven.

AttachmentSizeStatusTest resultOperations
1330922_4_xml_lang.patch3.56 KBIdlePASSED: [[SimpleTest]]: [MySQL] 33,803 pass(es).View details

#5

Wow, that was quick :) Conceptually I think this looks pretty good, waiting for the testbot. I agree modules using their own page markup should be looked at separately, not only for xml:lang probably also for HTML 5 conversion IMHO.

#6

@Gábor Hojtsy Ha, the html5 crew isn't kidding around :)

#7

Status:needs review» reviewed & tested by the community

Ok, I grepped around, and this fixes all that are not inside custom page templates (openid, book export and maintenance pages in themes). Do we have an issue for converting those to HTML5? Since those do not belong here, I consider this complete and ready to go.

#8

#9

Status:reviewed & tested by the community» fixed

Makes sense. Committed/pushed to 8.x.

#10

#11

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#12

Issue tags:+language-base

Tagging for base language system.

nobody click here