<?php
/**
- * @package MediaWiki
- * @subpackage Language
+ * @addtogroup Language
*/
if( !defined( 'MEDIAWIKI' ) ) {
# Read language names
global $wgLanguageNames;
-require_once( 'Names.php' );
+require_once( dirname(__FILE__) . '/Names.php' ) ;
global $wgInputEncoding, $wgOutputEncoding;
var $mConverter, $mVariants, $mCode, $mLoaded = false;
static public $mLocalisationKeys = array( 'fallback', 'namespaceNames',
- 'quickbarSettings', 'skinNames', 'mathNames',
+ 'skinNames', 'mathNames',
'bookstoreList', 'magicWords', 'messages', 'rtl', 'digitTransformTable',
'separatorTransformTable', 'fallback8bitEncoding', 'linkPrefixExtension',
'defaultUserOptionOverrides', 'linkTrail', 'namespaceAliases',
return User::getDefaultOptions();
}
+ function getFallbackLanguageCode() {
+ $this->load();
+ return $this->fallback;
+ }
+
/**
* Exports $wgBookstoreListEn
* @return array
}
/**
- * Get a namespace key by value, case insensetive.
+ * Get a namespace key by value, case insensitive.
+ * Only matches namespace names for the current language, not the
+ * canonical ones defined in Namespace.php.
+ *
+ * @param string $text
+ * @return mixed An integer if $text is a valid value otherwise false
+ */
+ function getLocalNsIndex( $text ) {
+ $this->load();
+ $lctext = $this->lc($text);
+ return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
+ }
+
+ /**
+ * Get a namespace key by value, case insensitive. Canonical namespace
+ * names override custom ones defined for the current language.
*
* @param string $text
* @return mixed An integer if $text is a valid value otherwise false
function getNsIndex( $text ) {
$this->load();
$lctext = $this->lc($text);
+ if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
}
}
function getQuickbarSettings() {
- $this->load();
- return $this->quickbarSettings;
+ return array(
+ $this->getMessage( 'qbsettings-none' ),
+ $this->getMessage( 'qbsettings-fixedleft' ),
+ $this->getMessage( 'qbsettings-fixedright' ),
+ $this->getMessage( 'qbsettings-floatingleft' ),
+ $this->getMessage( 'qbsettings-floatingright' )
+ );
}
function getSkinNames() {
if ( $tz === '' ) {
# Global offset in minutes.
if( isset($wgLocalTZoffset) ) {
- $hrDiff = $wgLocalTZoffset % 60;
- $minDiff = $wgLocalTZoffset - ($hrDiff * 60);
+ if( $wgLocalTZoffset >= 0 ) {
+ $hrDiff = floor($wgLocalTZoffset / 60);
+ } else {
+ $hrDiff = ceil($wgLocalTZoffset / 60);
+ }
+ $minDiff = $wgLocalTZoffset % 60;
}
} elseif ( strpos( $tz, ':' ) !== false ) {
$tzArray = explode( ':', $tz );
*/
function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
$this->load();
+
+ $ts = wfTimestamp( TS_MW, $ts );
+
if ( $adj ) {
$ts = $this->userAdjust( $ts, $timecorrection );
}
function iconv( $in, $out, $string ) {
# For most languages, this is a wrapper for iconv
- return iconv( $in, $out, $string );
+ return iconv( $in, $out . '//IGNORE', $string );
}
// callback functions for uc(), lc(), ucwords(), ucwordbreaks()
/**
* For translaing of expiry times
* @param string The validated block time in English
+ * @param $forContent, avoid html?
* @return Somehow translated block time
* @see LanguageFi.php for example implementation
*/
- function translateBlockExpiry( $str ) {
+ function translateBlockExpiry( $str, $forContent=false ) {
$scBlockExpiryOptions = $this->getMessageFromDB( 'ipboptions' );
if ( strpos($option, ":") === false )
continue;
list($show, $value) = explode(":", $option);
- if ( strcmp ( $str, $value) == 0 )
- return '<span title="' . htmlspecialchars($str). '">' .
- htmlspecialchars( trim( $show ) ) . '</span>';
+ if ( strcmp ( $str, $value) == 0 ) {
+ if ( $forContent )
+ return htmlspecialchars($str) . htmlspecialchars( trim( $show ) );
+ else
+ return '<span title="' . htmlspecialchars($str). '">' . htmlspecialchars( trim( $show ) ) . '</span>';
+ }
}
return $str;