r52298 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52297‎ | r52298 | r52299 >
Date:22:46, 22 June 2009
Author:brion
Status:deferred
Tags:
Comment:
* (bug 18878) Include UI-lang names of foreign languages in SiteMatrix if CLDR LanguageNames extension is present.
In a 'title' tooltip for table UI, in 'localname' attributes for raw and API output modes.
Modified paths:
  • /trunk/extensions/SiteMatrix/SiteMatrix_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SiteMatrix/SiteMatrix_body.php
@@ -185,6 +185,13 @@
186186 $this->outputHeader();
187187
188188 $matrix = new SiteMatrix();
 189+
 190+ if( class_exists( 'LanguageNames' ) ) {
 191+ global $wgLang;
 192+ $localLanguageNames = LanguageNames::getNames( $wgLang->getCode() );
 193+ } else {
 194+ $localLanguageNames = array();
 195+ }
189196
190197 if( $wgRequest->getVal( 'action' ) == 'raw' ){
191198 $wgOut->disable();
@@ -195,7 +202,14 @@
196203 echo "\t<matrix size=\"{$count}\">\n";
197204 foreach ( $matrix->getLangList() as $lang ) {
198205 $langhost = str_replace( '_', '-', $lang );
199 - echo "\t\t<language code=\"{$langhost}\" name=\"".htmlspecialchars( $wgLanguageNames[$lang] )."\">\n";
 206+ $attribs = array(
 207+ 'code' => $langhost,
 208+ 'name' => $wgLanguageNames[$lang],
 209+ );
 210+ if( isset( $localLanguageNames[$lang] ) ) {
 211+ $attribs['localname'] = $localLanguageNames[$lang];
 212+ }
 213+ echo "\t\t" . Xml::openElement( 'language', $attribs ) . "\n";
200214 foreach ( $matrix->getSites() as $site ) {
201215 if ( $matrix->exist( $lang, $site ) ) {
202216 $url = $matrix->getUrl( $lang, $site );
@@ -239,7 +253,11 @@
240254 foreach ( $matrix->getLangList() as $lang ) {
241255 $anchor = strtolower( '<a id="' . htmlspecialchars( $lang ) . '" name="' . htmlspecialchars( $lang ) . '"></a>' );
242256 $s .= '<tr>';
243 - $s .= '<td>' . $anchor . '<strong>' . $wgLanguageNames[$lang] . '</strong></td>';
 257+ $attribs = array();
 258+ if( isset( $localLanguageNames[$lang] ) ) {
 259+ $attribs['title'] = $localLanguageNames[$lang];
 260+ }
 261+ $s .= '<td>' . $anchor . Xml::element( 'strong', $attribs ) . $wgLanguageNames[$lang] . '</strong></td>';
244262 $langhost = str_replace( '_', '-', $lang );
245263 foreach ( $matrix->getNames() as $site => $name ) {
246264 $url = $matrix->getUrl( $lang, $site );
@@ -308,6 +326,14 @@
309327 $matrix_out = array(
310328 'count' => $matrix->getCount(),
311329 );
 330+
 331+ if( class_exists( 'LanguageNames' ) ) {
 332+ global $wgLang;
 333+ $localLanguageNames = LanguageNames::getNames( $wgLang->getCode() );
 334+ } else {
 335+ $localLanguageNames = array();
 336+ }
 337+
312338 foreach ( $matrix->getLangList() as $lang ) {
313339 $langhost = str_replace( '_', '-', $lang );
314340 $language = array(
@@ -315,6 +341,9 @@
316342 'name' => $wgLanguageNames[$lang],
317343 'site' => array(),
318344 );
 345+ if( isset( $localLanguageNames[$lang] ) ) {
 346+ $language['localname'] = $localLanguageNames[$lang];
 347+ }
319348
320349 foreach ( $matrix->getSites() as $site ) {
321350 if ( $matrix->exist( $lang, $site ) ) {

Status & tagging log