'defaultDateFormat', 'extraUserToggles' );
static public $mMergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames',
- 'dateFormats', 'defaultUserOptionOverrides' );
+ 'dateFormats', 'defaultUserOptionOverrides', 'magicWords' );
static public $mMergeableListKeys = array( 'extraUserToggles' );
}
}
- if ( $recursionLevel > 50 ) {
+ if ( $recursionLevel > 5 ) {
throw new MWException( "Language fallback loop detected when creating class $class\n" );
}
* @return string
*/
function getVariantname( $code ) {
- return wfMsg( "variantname-$code" );
+ return $this->getMessageFromDB( "variantname-$code" );
}
function specialPage( $name ) {
return $this->dateFormats;
}
+ function getDefaultDateFormat() {
+ $this->load();
+ return $this->defaultDateFormat;
+ }
+
function getDatePreferenceMigrationMap() {
$this->load();
return $this->datePreferenceMigrationMap;
}
function getUserToggle( $tog ) {
- return wfMsg( "tog-$tog" );
+ return $this->getMessageFromDB( "tog-$tog" );
}
/**
}
/**
- * Ugly hack to get a message maybe from the MediaWiki namespace, if this
- * language object is the content or user language.
+ * Ugly hack to get a message maybe from the MediaWiki namespace, if this
+ * language object is the content or user language.
*/
function getMessageFromDB( $msg ) {
global $wgContLang, $wgLang;
/**
* Calculate the day of the week for a 14-character timestamp
- * 0 for Sunday through to 6 for Saturday
+ * 1 for Sunday through to 7 for Saturday
* This takes about 100us on a slow computer
*/
static function calculateWeekday( $ts ) {
- return date( 'w', wfTimestamp( TS_UNIX, $ts ) );
+ return date( 'w', wfTimestamp( TS_UNIX, $ts ) ) + 1;
}
/**
}
function isMultibyte( $str ) {
- return (bool)preg_match( '/^[\x80-\xff]/', $str );
+ return (bool)preg_match( '/[\x80-\xff]/', $str );
}
function checkTitleEncoding( $s ) {
*
* @return string
*/
- function getDirMark() { return $this->isRTL() ? "\xE2\x80\x8F" : "\xE2\x80\x8E"; }
+ function getDirMark() {
+ return $this->isRTL() ? "\xE2\x80\x8F" : "\xE2\x80\x8E";
+ }
+
+ /**
+ * An arrow, depending on the language direction
+ *
+ * @return string
+ */
+ function getArrow() {
+ return $this->isRTL() ? '←' : '→';
+ }
/**
* To allow "foo[[bar]]" to extend the link over the whole word "foobar"
*
* @return bool
*/
- function linkPrefixExtension() {
+ function linkPrefixExtension() {
$this->load();
- return $this->linkPrefixExtension;
+ return $this->linkPrefixExtension;
}
function &getMagicWords() {
if ($i == $m) {
$s = $l[$i];
} else if ($i == $m - 1) {
- $s = $l[$i] . ' ' . wfMsg('and') . ' ' . $s;
+ $s = $l[$i] . ' ' . $this->getMessageFromDB( 'and' ) . ' ' . $s;
} else {
$s = $l[$i] . ', ' . $s;
}
*/
function translateBlockExpiry( $str ) {
- $scBlockExpiryOptions = wfMsg( 'ipboptions' );
+ $scBlockExpiryOptions = $this->getMessageFromDB( 'ipboptions' );
if ( $scBlockExpiryOptions == '-') {
return $str;
throw new MWException( "Error: Circular fallback reference in language code $code" );
}
$recursionGuard[$code] = true;
- $newDeps = self::loadLocalisation( $fallback );
+ $newDeps = self::loadLocalisation( $fallback, $disableCache );
unset( $recursionGuard[$code] );
$secondary = self::$mLocalisationCache[$fallback];
return self::$mLocalisationCache[$code]['messages'];
}
+ /**
+ * Get a message for a given language
+ */
+ static function getMessageFor( $key, $code ) {
+ self::loadLocalisation( $code );
+ return @self::$mLocalisationCache[$code]['messages'][$key];
+ }
+
/**
* Load localisation data for this object
*/
# Allowing full message-style parsing would make simple requests
# such as action=raw much more expensive than they need to be.
# This will hopefully cover most cases.
- if ( preg_match( '/{{grammar:(.*?)\|(.*?)}}/i', $talk, $m ) ) {
- $talk = str_replace( ' ', '_',
- $this->convertGrammar( trim( $m[2] ), trim( $m[1] ) )
- );
- }
+ $talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
+ array( &$this, 'replaceGrammarInNamespace' ), $talk );
+ $talk = str_replace( ' ', '_', $talk );
$this->namespaceNames[NS_PROJECT_TALK] = $talk;
}
wfProfileOut( __METHOD__ );
}
+ function replaceGrammarInNamespace( $m ) {
+ return $this->convertGrammar( trim( $m[2] ), trim( $m[1] ) );
+ }
+
static function getCaseMaps() {
static $wikiUpperChars, $wikiLowerChars;
global $IP;
}
}
-/** @deprecated */
-class LanguageUtf8 extends Language {}
?>