Update core usage of getLanguageName[s].

This commit is contained in:
Robin Pepermans 2012-03-08 20:56:26 +00:00
parent b6ffd105fa
commit 9184dc83d6
15 changed files with 24 additions and 37 deletions

View 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 );

View 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" ),

View 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(),

View 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" ),

View 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();

View 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 );
}

View 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 ) {

View 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;

View 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;

View 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' ) ) .

View 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 );
}

View 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 );
}

View 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 );
}

View 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'] );

View 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