r113403 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113402‎ | r113403 | r113404 >
Date:20:56, 8 March 2012
Author:robin
Status:resolved
Tags:i18nreview 
Comment:
Update core usage of getLanguageName[s].
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/SkinLegacy.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /trunk/phase3/includes/cache/MessageCache.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)
  • /trunk/phase3/includes/media/FormatMetadata.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialAllmessages.php (modified) (history)
  • /trunk/phase3/maintenance/language/StatOutputs.php (modified) (history)
  • /trunk/phase3/maintenance/language/checkLanguage.inc (modified) (history)
  • /trunk/phase3/maintenance/language/languages.inc (modified) (history)
  • /trunk/phase3/maintenance/language/transstat.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildLocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildLocalisationCache.php
@@ -72,7 +72,7 @@
7373 }
7474 $lc = new LocalisationCache_BulkLoad( $conf );
7575
76 - $codes = array_keys( Language::getLanguageNames( true ) );
 76+ $codes = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
7777 sort( $codes );
7878
7979 // Initialise and split into chunks
Index: trunk/phase3/maintenance/language/checkLanguage.inc
@@ -402,7 +402,6 @@
403403 * Output the checks results as wiki text.
404404 */
405405 function outputWiki() {
406 - global $wgContLang;
407406 $detailText = '';
408407 $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
409408 foreach ( $this->results as $code => $results ) {
@@ -438,7 +437,7 @@
439438 # Don't list languages without problems
440439 continue;
441440 }
442 - $language = $wgContLang->getLanguageName( $code );
 441+ $language = Language::fetchLanguageName( $code );
443442 $rows[] = "| $language || $code || $problems || " . implode( ' || ', $numbers );
444443 }
445444
Index: trunk/phase3/maintenance/language/StatOutputs.php
@@ -46,7 +46,7 @@
4747 /** Outputs WikiText */
4848 class wikiStatsOutput extends statsOutput {
4949 function heading() {
50 - global $wgDummyLanguageCodes, $wgContLang;
 50+ global $wgDummyLanguageCodes;
5151 $version = SpecialVersion::getVersion( 'nodb' );
5252 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
5353 echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
@@ -55,7 +55,7 @@
5656 if( is_array( $wgDummyLanguageCodes ) ) {
5757 $dummyCodes = array();
5858 foreach( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
59 - $dummyCodes[] = $wgContLang->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
 59+ $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
6060 }
6161 echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes );
6262 }
Index: trunk/phase3/maintenance/language/transstat.php
@@ -102,7 +102,7 @@
103103 }
104104
105105 # Calculate the numbers
106 - $language = $wgContLang->getLanguageName( $code );
 106+ $language = Language::fetchLanguageName( $code );
107107 $fallback = $wgLanguages->getFallback( $code );
108108 $messages = $wgLanguages->getMessages( $code );
109109 $messagesNumber = count( $messages['translated'] );
Index: trunk/phase3/maintenance/language/languages.inc
@@ -54,7 +54,7 @@
5555 $this->mOptionalMessages = array_merge( $wgOptionalMessages, $wgEXIFMessages );
5656 }
5757
58 - $this->mLanguages = array_keys( Language::getLanguageNames( true ) );
 58+ $this->mLanguages = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
5959 sort( $this->mLanguages );
6060 }
6161
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1322,7 +1322,7 @@
13231323 return $wgLang;
13241324 }
13251325
1326 - $validCodes = array_keys( Language::getLanguageNames() );
 1326+ $validCodes = array_keys( Language::fetchLanguageNames() );
13271327 if( in_array( $langcode, $validCodes ) ) {
13281328 # $langcode corresponds to a valid language.
13291329 return Language::factory( $langcode );
Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -485,7 +485,7 @@
486486 public function getAcceptLanguage() {
487487 global $wgLanguageCode, $wgRequest;
488488
489 - $mwLanguages = Language::getLanguageNames();
 489+ $mwLanguages = Language::fetchLanguageNames();
490490 $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
491491
492492 foreach ( $headerLanguages as $lang ) {
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -162,7 +162,7 @@
163163 $userLang = $r->getVal( 'uselang' );
164164 $contLang = $r->getVal( 'ContLang' );
165165
166 - $languages = Language::getLanguageNames();
 166+ $languages = Language::fetchLanguageNames();
167167 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
168168 if ( !$lifetime ) {
169169 $lifetime = 1440; // PHP default
@@ -233,7 +233,7 @@
234234 $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
235235 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
236236
237 - $languages = Language::getLanguageNames();
 237+ $languages = Language::fetchLanguageNames();
238238 ksort( $languages );
239239 foreach ( $languages as $code => $lang ) {
240240 if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -273,13 +273,8 @@
274274
275275 $params = $this->extractRequestParams();
276276 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
 277+ $langNames = Language::fetchLanguageNames( $langCode );
277278
278 - if( $langCode ) {
279 - $langNames = Language::getTranslatedLanguageNames( $langCode );
280 - } else {
281 - $langNames = Language::getLanguageNames();
282 - }
283 -
284279 $getPrefixes = Interwiki::getAllPrefixes( $local );
285280 $data = array();
286281
@@ -479,13 +474,8 @@
480475 public function appendLanguages( $property ) {
481476 $params = $this->extractRequestParams();
482477 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
 478+ $langNames = Language::getLanguageNames( $langCode );
483479
484 - if( $langCode ) {
485 - $langNames = Language::getTranslatedLanguageNames( $langCode );
486 - } else {
487 - $langNames = Language::getLanguageNames();
488 - }
489 -
490480 $data = array();
491481
492482 foreach ( $langNames as $code => $name ) {
Index: trunk/phase3/includes/api/ApiParse.php
@@ -399,7 +399,7 @@
400400 $langs = array();
401401 foreach ( $languages as $l ) {
402402 $nt = Title::newFromText( $l );
403 - $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
 403+ $text = Language::fetchLanguageName( $nt->getInterwiki() );
404404
405405 $langs[] = Html::element( 'a',
406406 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
Index: trunk/phase3/includes/media/FormatMetadata.php
@@ -800,7 +800,7 @@
801801 break;
802802
803803 case 'LanguageCode':
804 - $lang = $wgLang->getLanguageName( strtolower( $val ) );
 804+ $lang = Language::fetchLanguageName( strtolower( $val ), $wgLang );
805805 if ($lang) {
806806 $val = htmlspecialchars( $lang );
807807 } else {
@@ -941,7 +941,6 @@
942942 * this is treated as wikitext not html).
943943 */
944944 private static function langItem( $value, $lang, $default = false, $noHtml = false ) {
945 - global $wgContLang;
946945 if ( $lang === false && $default === false) {
947946 throw new MWException('$lang and $default cannot both '
948947 . 'be false.');
@@ -966,11 +965,11 @@
967966 }
968967
969968 $lowLang = strtolower( $lang );
970 - $langName = $wgContLang->getLanguageName( $lowLang );
 969+ $langName = Language::fetchLanguageName( $lowLang );
971970 if ( $langName === '' ) {
972971 //try just the base language name. (aka en-US -> en ).
973972 list( $langPrefix ) = explode( '-', $lowLang, 2 );
974 - $langName = $wgContLang->getLanguageName( $langPrefix );
 973+ $langName = Language::fetchLanguageName( $langPrefix );
975974 if ( $langName === '' ) {
976975 // give up.
977976 $langName = $lang;
Index: trunk/phase3/includes/cache/MessageCache.php
@@ -497,7 +497,7 @@
498498 if ( $code === 'en' ) {
499499 // Delete all sidebars, like for example on action=purge on the
500500 // sidebar messages
501 - $codes = array_keys( Language::getLanguageNames() );
 501+ $codes = array_keys( Language::fetchLanguageNames() );
502502 }
503503
504504 global $wgMemc;
@@ -869,7 +869,7 @@
870870 * Clear all stored messages. Mainly used after a mass rebuild.
871871 */
872872 function clear() {
873 - $langs = Language::getLanguageNames( false );
 873+ $langs = Language::fetchLanguageNames( null, 'mw' );
874874 foreach ( array_keys($langs) as $code ) {
875875 # Global cache
876876 $this->mMemc->delete( wfMemcKey( 'messages', $code ) );
@@ -891,8 +891,7 @@
892892 }
893893
894894 $lang = array_pop( $pieces );
895 - $validCodes = Language::getLanguageNames();
896 - if( !array_key_exists( $lang, $validCodes ) ) {
 895+ if( !Language::fetchLanguageName( $lang, null, 'mw' ) ) {
897896 return array( $key, $wgLanguageCode );
898897 }
899898
Index: trunk/phase3/includes/SkinLegacy.php
@@ -348,7 +348,7 @@
349349 }
350350
351351 function otherLanguages() {
352 - global $wgOut, $wgLang, $wgContLang, $wgHideInterlanguageLinks;
 352+ global $wgOut, $wgLang, $wgHideInterlanguageLinks;
353353
354354 if ( $wgHideInterlanguageLinks ) {
355355 return '';
@@ -375,7 +375,7 @@
376376 $first = false;
377377
378378 $nt = Title::newFromText( $l );
379 - $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
 379+ $text = Language::fetchLanguageName( $nt->getInterwiki() );
380380
381381 $s .= Html::element( 'a',
382382 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
Index: trunk/phase3/includes/SkinTemplate.php
@@ -428,8 +428,8 @@
429429 if ( $nt ) {
430430 $language_urls[] = array(
431431 'href' => $nt->getFullURL(),
432 - 'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
433 - $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
 432+ 'text' => ( Language::fetchLanguageName( $nt->getInterwiki() ) != '' ?
 433+ Language::fetchLanguageName( $nt->getInterwiki() ) : $l ),
434434 'title' => $nt->getText(),
435435 'class' => $class,
436436 'lang' => $nt->getInterwiki(),
Index: trunk/phase3/includes/specials/SpecialAllmessages.php
@@ -146,7 +146,7 @@
147147 function buildForm() {
148148 global $wgScript;
149149
150 - $languages = Language::getLanguageNames( false );
 150+ $languages = Language::fetchLanguageNames( null, 'mw' );
151151 ksort( $languages );
152152
153153 $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .

Follow-up revisions

RevisionCommit summaryAuthorDate
r113552fix r113403robin02:07, 10 March 2012

Status & tagging log