Update core usage of getLanguageName[s].
authorRobin Pepermans <robin@users.mediawiki.org>
Thu, 8 Mar 2012 20:56:26 +0000 (20:56 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Thu, 8 Mar 2012 20:56:26 +0000 (20:56 +0000)
15 files changed:
includes/GlobalFunctions.php
includes/SkinLegacy.php
includes/SkinTemplate.php
includes/api/ApiParse.php
includes/api/ApiQuerySiteinfo.php
includes/cache/MessageCache.php
includes/installer/WebInstaller.php
includes/installer/WebInstallerPage.php
includes/media/FormatMetadata.php
includes/specials/SpecialAllmessages.php
maintenance/language/StatOutputs.php
maintenance/language/checkLanguage.inc
maintenance/language/languages.inc
maintenance/language/transstat.php
maintenance/rebuildLocalisationCache.php

index 3151755..ce9c287 100644 (file)
@@ -1322,7 +1322,7 @@ function wfGetLangObj( $langcode = false ) {
                return $wgLang;
        }
 
-       $validCodes = array_keys( Language::getLanguageNames() );
+       $validCodes = array_keys( Language::fetchLanguageNames() );
        if( in_array( $langcode, $validCodes ) ) {
                # $langcode corresponds to a valid language.
                return Language::factory( $langcode );
index 7cdd0a0..4db9da4 100644 (file)
@@ -348,7 +348,7 @@ class LegacyTemplate extends BaseTemplate {
        }
 
        function otherLanguages() {
-               global $wgOut, $wgLang, $wgContLang, $wgHideInterlanguageLinks;
+               global $wgOut, $wgLang, $wgHideInterlanguageLinks;
 
                if ( $wgHideInterlanguageLinks ) {
                        return '';
@@ -375,7 +375,7 @@ class LegacyTemplate extends BaseTemplate {
                        $first = false;
 
                        $nt = Title::newFromText( $l );
-                       $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
+                       $text = Language::fetchLanguageName( $nt->getInterwiki() );
 
                        $s .= Html::element( 'a',
                                array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
index 68e595b..2d198f9 100644 (file)
@@ -428,8 +428,8 @@ class SkinTemplate extends Skin {
                                if ( $nt ) {
                                        $language_urls[] = array(
                                                'href' => $nt->getFullURL(),
-                                               'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
-                                                                       $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
+                                               'text' => ( Language::fetchLanguageName( $nt->getInterwiki() ) != '' ?
+                                                                       Language::fetchLanguageName( $nt->getInterwiki() ) : $l ),
                                                'title' => $nt->getText(),
                                                'class' => $class,
                                                'lang' => $nt->getInterwiki(),
index 893491b..141f779 100644 (file)
@@ -399,7 +399,7 @@ class ApiParse extends ApiBase {
                $langs = array();
                foreach ( $languages as $l ) {
                        $nt = Title::newFromText( $l );
-                       $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
+                       $text = Language::fetchLanguageName( $nt->getInterwiki() );
 
                        $langs[] = Html::element( 'a',
                                array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
index e95de21..c83be79 100644 (file)
@@ -273,12 +273,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $params = $this->extractRequestParams();
                $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langNames = Language::fetchLanguageNames( $langCode );
 
                $getPrefixes = Interwiki::getAllPrefixes( $local );
                $data = array();
@@ -479,12 +474,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        public function appendLanguages( $property ) {
                $params = $this->extractRequestParams();
                $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langNames = Language::getLanguageNames( $langCode );
 
                $data = array();
 
index a1d76dc..d1e658b 100644 (file)
@@ -497,7 +497,7 @@ class MessageCache {
                if ( $code === 'en'  ) {
                        // Delete all sidebars, like for example on action=purge on the
                        // sidebar messages
-                       $codes = array_keys( Language::getLanguageNames() );
+                       $codes = array_keys( Language::fetchLanguageNames() );
                }
 
                global $wgMemc;
@@ -869,7 +869,7 @@ class MessageCache {
         * Clear all stored messages. Mainly used after a mass rebuild.
         */
        function clear() {
-               $langs = Language::getLanguageNames( false );
+               $langs = Language::fetchLanguageNames( null, 'mw' );
                foreach ( array_keys($langs) as $code ) {
                        # Global cache
                        $this->mMemc->delete( wfMemcKey( 'messages', $code ) );
@@ -891,8 +891,7 @@ class MessageCache {
                }
 
                $lang = array_pop( $pieces );
-               $validCodes = Language::getLanguageNames();
-               if( !array_key_exists( $lang, $validCodes ) ) {
+               if( !Language::fetchLanguageName( $lang, null, 'mw' ) ) {
                        return array( $key, $wgLanguageCode );
                }
 
index c340d9a..eeeb768 100644 (file)
@@ -485,7 +485,7 @@ class WebInstaller extends Installer {
        public function getAcceptLanguage() {
                global $wgLanguageCode, $wgRequest;
 
-               $mwLanguages = Language::getLanguageNames();
+               $mwLanguages = Language::fetchLanguageNames();
                $headerLanguages = array_keys( $wgRequest->getAcceptLang() );
 
                foreach ( $headerLanguages as $lang ) {
index aa45f80..73a5ef2 100644 (file)
@@ -162,7 +162,7 @@ class WebInstaller_Language extends WebInstallerPage {
                $userLang = $r->getVal( 'uselang' );
                $contLang = $r->getVal( 'ContLang' );
 
-               $languages = Language::getLanguageNames();
+               $languages = Language::fetchLanguageNames();
                $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
                if ( !$lifetime ) {
                        $lifetime = 1440; // PHP default
@@ -233,7 +233,7 @@ class WebInstaller_Language extends WebInstallerPage {
                $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
                                'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
 
-               $languages = Language::getLanguageNames();
+               $languages = Language::fetchLanguageNames();
                ksort( $languages );
                foreach ( $languages as $code => $lang ) {
                        if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
index 7125c96..2416252 100644 (file)
@@ -800,7 +800,7 @@ class FormatMetadata {
                                        break;
 
                                case 'LanguageCode':
-                                       $lang = $wgLang->getLanguageName( strtolower( $val ) );
+                                       $lang = Language::fetchLanguageName( strtolower( $val ), $wgLang );
                                        if ($lang) {
                                                $val = htmlspecialchars( $lang );
                                        } else {
@@ -941,7 +941,6 @@ class FormatMetadata {
         *      this is treated as wikitext not html).
         */
        private static function langItem( $value, $lang, $default = false, $noHtml = false ) {
-               global $wgContLang;
                if ( $lang === false && $default === false) {
                        throw new MWException('$lang and $default cannot both '
                                . 'be false.');
@@ -966,11 +965,11 @@ class FormatMetadata {
                }
 
                $lowLang = strtolower( $lang );
-               $langName = $wgContLang->getLanguageName( $lowLang );
+               $langName = Language::fetchLanguageName( $lowLang );
                if ( $langName === '' ) {
                        //try just the base language name. (aka en-US -> en ).
                        list( $langPrefix ) = explode( '-', $lowLang, 2 );
-                       $langName = $wgContLang->getLanguageName( $langPrefix );
+                       $langName = Language::fetchLanguageName( $langPrefix );
                        if ( $langName === '' ) {
                                // give up.
                                $langName = $lang;
index d7acd86..0c03871 100644 (file)
@@ -146,7 +146,7 @@ class AllmessagesTablePager extends TablePager {
        function buildForm() {
                global $wgScript;
 
-               $languages = Language::getLanguageNames( false );
+               $languages = Language::fetchLanguageNames( null, 'mw' );
                ksort( $languages );
 
                $out  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .
index befd0d7..d77029e 100644 (file)
@@ -46,7 +46,7 @@ class statsOutput {
 /** Outputs WikiText */
 class wikiStatsOutput extends statsOutput {
        function heading() {
-               global $wgDummyLanguageCodes, $wgContLang;
+               global $wgDummyLanguageCodes;
                $version = SpecialVersion::getVersion( 'nodb' );
                echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
                echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
@@ -55,7 +55,7 @@ class wikiStatsOutput extends statsOutput {
                if( is_array( $wgDummyLanguageCodes ) ) {
                        $dummyCodes = array();
                        foreach( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
-                               $dummyCodes[] = $wgContLang->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
+                               $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
                        }
                        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 );
                }
index 9865257..11b00e1 100644 (file)
@@ -402,7 +402,6 @@ ENDS;
         * Output the checks results as wiki text.
         */
        function outputWiki() {
-               global $wgContLang;
                $detailText = '';
                $rows[] = '! Language !! Code !! Total !! ' . implode( ' !! ', array_diff( $this->checks, $this->nonMessageChecks() ) );
                foreach ( $this->results as $code => $results ) {
@@ -438,7 +437,7 @@ ENDS;
                                # Don't list languages without problems
                                continue;
                        }
-                       $language = $wgContLang->getLanguageName( $code );
+                       $language = Language::fetchLanguageName( $code );
                        $rows[] = "| $language || $code || $problems || " . implode( ' || ', $numbers );
                }
 
index 2b5c449..15fa712 100644 (file)
@@ -54,7 +54,7 @@ class languages {
                        $this->mOptionalMessages = array_merge( $wgOptionalMessages, $wgEXIFMessages );
                }
 
-               $this->mLanguages = array_keys( Language::getLanguageNames( true ) );
+               $this->mLanguages = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
                sort( $this->mLanguages );
        }
 
index 36f214b..a298841 100644 (file)
@@ -102,7 +102,7 @@ foreach ( $wgLanguages->getLanguages() as $code ) {
        }
 
        # Calculate the numbers
-       $language = $wgContLang->getLanguageName( $code );
+       $language = Language::fetchLanguageName( $code );
        $fallback = $wgLanguages->getFallback( $code );
        $messages = $wgLanguages->getMessages( $code );
        $messagesNumber = count( $messages['translated'] );
index d1e47ee..5915a6b 100644 (file)
@@ -72,7 +72,7 @@ class RebuildLocalisationCache extends Maintenance {
                }
                $lc = new LocalisationCache_BulkLoad( $conf );
 
-               $codes = array_keys( Language::getLanguageNames( true ) );
+               $codes = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
                sort( $codes );
 
                // Initialise and split into chunks