function markNoConversion($text, $noParse=false) {return $text;}
function convertCategoryKey( $key ) {return $key; }
function convertLinkToAllVariants($text){ return array( $this->mLang->getCode() => $text); }
- function setNoTitleConvert(){}
+ function armourMath($text){ return $text; }
}
#--------------------------------------------------------------------------
*/
function getNsIndex( $text ) {
$this->load();
- $index = @$this->mNamespaceIds[$this->lc($text)];
- if ( is_null( $index ) ) {
- return false;
- } else {
- return $index;
- }
+ $lctext = $this->lc($text);
+ return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
}
/**
* Get language names, indexed by code.
* If $customisedOnly is true, only returns codes with a messages file
*/
- function getLanguageNames( $customisedOnly = false ) {
+ public static function getLanguageNames( $customisedOnly = false ) {
global $wgLanguageNames;
if ( !$customisedOnly ) {
return $wgLanguageNames;
function getMessage( $key ) {
$this->load();
- return @$this->messages[$key];
+ return isset( $this->messages[$key] ) ? $this->messages[$key] : null;
}
function getAllMessages() {
* @return string
*/
function stripForSearch( $string ) {
+ global $wgDBtype;
+ if ( $wgDBtype != 'mysql' ) {
+ return $string;
+ }
+
# MySQL fulltext index doesn't grok utf-8, so we
# need to fold cases and convert to hex
return $number;
}
+ function parseFormattedNumber( $number ) {
+ $s = $this->digitTransformTable();
+ if (!is_null($s)) { $number = strtr($number, array_flip($s)); }
+
+ $s = $this->separatorTransformTable();
+ if (!is_null($s)) { $number = strtr($number, array_flip($s)); }
+
+ $number = strtr( $number, array (',' => '') );
+ return $number;
+ }
+
/**
* Adds commas to a given number
*
* @param string $wordform1
* @param string $wordform2
* @param string $wordform3 (optional)
+ * @param string $wordform4 (optional)
+ * @param string $wordform5 (optional)
* @return string
*/
- function convertPlural( $count, $w1, $w2, $w3) {
- return $count == '1' ? $w1 : $w2;
+ function convertPlural( $count, $w1, $w2, $w3, $w4, $w5) {
+ return ( $count == '1' || $count == '-1' ) ? $w1 : $w2;
}
/**
return $this->mConverter->parserConvert( $text, $parser );
}
- # Tell the converter that it shouldn't convert titles
- function setNoTitleConvert(){
- $this->mConverter->setNotitleConvert();
- }
-
# Check if this is a language with variants
function hasVariants(){
return sizeof($this->getVariants())>1;
}
+ # Put custom tags (e.g. -{ }-) around math to prevent conversion
+ function armourMath($text){
+ return $this->mConverter->armourMath($text);
+ }
+
/**
* Perform output conversion on a string, and encode for safe HTML output.
$cache = wfGetPrecompiledData( self::getFileName( "Messages", $code, '.ser' ) );
if ( $cache ) {
self::$mLocalisationCache[$code] = $cache;
- wfDebug( "Got localisation for $code from precompiled data file\n" );
+ wfDebug( "Language::loadLocalisation(): got localisation for $code from precompiled data file\n" );
wfProfileOut( __METHOD__ );
return self::$mLocalisationCache[$code]['deps'];
}
if ( self::isLocalisationOutOfDate( $cache ) ) {
$wgMemc->delete( $memcKey );
$cache = false;
- wfDebug( "Localisation cache for $code had expired due to update of $file\n" );
+ wfDebug( "Language::loadLocalisation(): localisation cache for $code had expired due to update of $file\n" );
} else {
self::$mLocalisationCache[$code] = $cache;
- wfDebug( "Got localisation for $code from cache\n" );
+ wfDebug( "Language::loadLocalisation(): got localisation for $code from cache\n" );
wfProfileOut( __METHOD__ );
return $cache['deps'];
}
wfProfileIn( __METHOD__ );
}
+ # Default fallback, may be overridden when the messages file is included
if ( $code != 'en' ) {
$fallback = 'en';
} else {
$fallback = false;
}
-
+
# Load the primary localisation from the source file
$filename = self::getMessagesFileName( $code );
if ( !file_exists( $filename ) ) {
- wfDebug( "No localisation file for $code, using implicit fallback to en\n" );
+ wfDebug( "Language::loadLocalisation(): no localisation file for $code, using implicit fallback to en\n" );
$cache = array();
$deps = array();
} else {
$deps = array( $filename => filemtime( $filename ) );
require( $filename );
$cache = compact( self::$mLocalisationKeys );
- wfDebug( "Got localisation for $code from source\n" );
+ wfDebug( "Language::loadLocalisation(): got localisation for $code from source\n" );
}
-
+
if ( !empty( $fallback ) ) {
# Load the fallback localisation, with a circular reference guard
if ( isset( $recursionGuard[$code] ) ) {
*/
static function getMessageFor( $key, $code ) {
self::loadLocalisation( $code );
- return @self::$mLocalisationCache[$code]['messages'][$key];
+ return isset( self::$mLocalisationCache[$code]['messages'][$key] ) ? self::$mLocalisationCache[$code]['messages'][$key] : null;
}
/**