# Read language names
global $wgLanguageNames;
-require_once( dirname( __FILE__ ) . '/Names.php' );
+require_once( __DIR__ . '/Names.php' );
if ( function_exists( 'mb_strtoupper' ) ) {
mb_internal_encoding( 'UTF-8' );
*/
public function setNamespaces( array $namespaces ) {
$this->namespaceNames = $namespaces;
+ $this->mNamespaceIds = null;
+ }
+
+ /**
+ * Resets all of the namespace caches. Mainly used for testing
+ */
+ public function resetNamespaces( ) {
+ $this->namespaceNames = null;
+ $this->mNamespaceIds = null;
+ $this->namespaceAliases = null;
}
/**
* @return string
*/
function getMessageFromDB( $msg ) {
- return wfMsgExt( $msg, array( 'parsemag', 'language' => $this ) );
+ return wfMessage( $msg )->inLanguage( $this )->text();
}
/**
*
* An example of this function being called:
* <code>
- * wfMsg( 'message', $wgLang->formatNum( $num ) )
+ * wfMessage( 'message' )->numParams( $num )->text()
* </code>
*
* See LanguageGu.php for the Gujarati implementation and
function listToText( array $l ) {
$s = '';
$m = count( $l ) - 1;
-
+
if ( $m === 0 ) {
return $l[0];
} elseif ( $m === 1 ) {
*/
function commaList( array $list ) {
return implode(
- wfMsgExt(
- 'comma-separator',
- array( 'parsemag', 'escapenoentities', 'language' => $this )
- ),
+ wfMessage( 'comma-separator' )->inLanguage( $this )->escaped(),
$list
);
}
*/
function semicolonList( array $list ) {
return implode(
- wfMsgExt(
- 'semicolon-separator',
- array( 'parsemag', 'escapenoentities', 'language' => $this )
- ),
+ wfMessage( 'semicolon-separator' )->inLanguage( $this )->escaped(),
$list
);
}
*/
function pipeList( array $list ) {
return implode(
- wfMsgExt(
- 'pipe-separator',
- array( 'escapenoentities', 'language' => $this )
- ),
+ wfMessage( 'pipe-separator' )->inLanguage( $this )->escaped(),
$list
);
}
function truncate( $string, $length, $ellipsis = '...', $adjustLength = true ) {
# Use the localized ellipsis character
if ( $ellipsis == '...' ) {
- $ellipsis = wfMsgExt( 'ellipsis', array( 'escapenoentities', 'language' => $this ) );
+ $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this )->escaped();
}
# Check if there is no need to truncate
if ( $length == 0 ) {
function truncateHtml( $text, $length, $ellipsis = '...' ) {
# Use the localized ellipsis character
if ( $ellipsis == '...' ) {
- $ellipsis = wfMsgExt( 'ellipsis', array( 'escapenoentities', 'language' => $this ) );
+ $ellipsis = wfMessage( 'ellipsis' )->inLanguage( $this )->escaped();
}
# Check if there is clearly no need to truncate
if ( $length <= 0 ) {
$dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) .
$this->getDirMark();
$details = $details ? $dirmark . $this->getMessageFromDB( 'word-separator' ) .
- wfMsgExt( 'parentheses', array( 'escape', 'replaceafter', 'language' => $this ), $details ) : '';
+ wfMessage( 'parentheses' )->rawParams( $details )->inLanguage( $this )->escaped() : '';
return $page . $details;
}
* @return array Associative array with plural form, and plural rule as key-value pairs
*/
public function getCompiledPluralRules() {
- return self::$dataCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' );
+ $pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' );
+ $fallbacks = Language::getFallbacksFor( $this->mCode );
+ if ( !$pluralRules ) {
+ foreach ( $fallbacks as $fallbackCode ) {
+ $pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'compiledPluralRules' );
+ if ( $pluralRules ) {
+ break;
+ }
+ }
+ }
+ return $pluralRules;
}
/**
* @return array Associative array with plural form, and plural rule as key-value pairs
*/
public function getPluralRules() {
- return self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRules' );
+ $pluralRules = self::$dataCache->getItem( strtolower( $this->mCode ), 'pluralRules' );
+ $fallbacks = Language::getFallbacksFor( $this->mCode );
+ if ( !$pluralRules ) {
+ foreach ( $fallbacks as $fallbackCode ) {
+ $pluralRules = self::$dataCache->getItem( strtolower( $fallbackCode ), 'pluralRules' );
+ if ( $pluralRules ) {
+ break;
+ }
+ }
+ }
+ return $pluralRules;
}
/**