r62312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62311‎ | r62312 | r62313 >
Date:17:25, 11 February 2010
Author:simetrical
Status:ok (Comments)
Tags:
Comment:
War on xml:lang

There is no reason to use this in HTML in addition to the lang
attribute. No spec requires it (AFAIK) and it's completely redundant.
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)
  • /trunk/phase3/includes/OutputHandler.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/templates/NoLocalSettings.php (modified) (history)
  • /trunk/phase3/includes/templates/PHP4.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputHandler.php
@@ -130,7 +130,7 @@
131131
132132 $out = <<<EOT
133133 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
134 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
 134+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
135135 <head>
136136 <title>HTML validation error</title>
137137 <style>
Index: trunk/phase3/includes/OutputPage.php
@@ -2113,7 +2113,7 @@
21142114 foreach($wgXhtmlNamespaces as $tag => $ns) {
21152115 $ret .= "xmlns:{$tag}=\"{$ns}\" ";
21162116 }
2117 - $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
 2117+ $ret .= "lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
21182118 }
21192119
21202120 $ret .= "<head>\n";
Index: trunk/phase3/includes/SkinTemplate.php
@@ -314,7 +314,7 @@
315315 $lang = $wgLang->getCode();
316316 $dir = $wgLang->getDir();
317317 if ( $lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir() ) {
318 - $attrs = " lang='$lang' xml:lang='$lang' dir='$dir'";
 318+ $attrs = " lang='$lang' dir='$dir'";
319319
320320 $tpl->set( 'userlangattributes', $attrs );
321321
Index: trunk/phase3/includes/templates/PHP4.php
@@ -27,7 +27,7 @@
2828
2929 ?>
3030 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
31 -<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
 31+<html xmlns='http://www.w3.org/1999/xhtml' lang='en'>
3232 <head>
3333 <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?></title>
3434 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
Index: trunk/phase3/includes/templates/NoLocalSettings.php
@@ -35,7 +35,7 @@
3636 }
3737 ?>
3838 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39 -<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
 39+<html xmlns='http://www.w3.org/1999/xhtml' lang='en'>
4040 <head>
4141 <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ) ?></title>
4242 <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
Index: trunk/phase3/config/Installer.php
@@ -112,7 +112,7 @@
113113
114114 ?>
115115 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
116 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
 116+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
117117 <head>
118118 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
119119 <meta name="robots" content="noindex,nofollow"/>

Follow-up revisions

RevisionCommit summaryAuthorDate
r64281Remove a use of xml:lang that I missed in r62312...simetrical01:37, 28 March 2010
r64282Backport r64281 "Remove a use of xml:lang that I missed in r62312"...simetrical01:41, 28 March 2010

Comments

#Comment by Locos epraix (talk | contribs)   16:53, 12 February 2010

Completely redundant? And what about if it could be configurable with $wgHtml5?

#Comment by Simetrical (talk | contribs)   17:28, 12 February 2010

Yes, it's completely redundant, because there's a lang attribute in every case. Every place it's used, you have lang="foo" xml:lang="foo", with the language repeated twice. It's just as redundant in XHTML1 as in HTML5, and both permit xml:lang but don't require it, so I don't see any reason to keep it.

Why should we have it? Are you aware of any actual applications that require it?

#Comment by Locos epraix (talk | contribs)   17:50, 12 February 2010

Nop, don't any use of xml:lang, just wondering about its use.

#Comment by Tim Starling (talk | contribs)   06:52, 19 February 2010

I think you need to find some more important things to declare war on ;)

#Comment by Simetrical (talk | contribs)   18:02, 19 February 2010

Hmm, how about those edit <link>s we have in the <head>? It would make much more sense if we just used <a rel=edit> on the in-page edit links.

#Comment by Tim Starling (talk | contribs)   23:46, 19 February 2010

The <link> is needed to make MW work with the Universal Edit Button extension (http://universaleditbutton.org/Add_The_Link). Try again.

I see that you have been making progress in your war on spaces (e.g. r62311). Maybe you should try declaring war on other ASCII characters, like "," or "#".

#Comment by Simetrical (talk | contribs)   00:18, 21 February 2010

Universal Edit Button should be able to use <a rel=edit> too. If not, it should be fixed. <a rel=foo href=bar> is usually supposed to include the same semantics as <link rel=foo href=bar> (although not for some rel values, like stylesheet). I tried to get rel=edit added to the HTML5 spec (http://www.w3.org/Bugs/Public/show_bug.cgi?id=8735), but it's apparently not clear right now who will be maintaining the registry of rel values, so Hixie decided he wouldn't add it until that was sorted out.

I like "," and "#". I could declare war on "//" (what's the point in that extra byte, especially if you try to keep under 80 chars per line?), but that would probably be unhelpful.

Status & tagging log