$fname = 'wfMsgReal';
wfProfileIn( $fname );
- if( $forContent ) {
- /**
- * Message is needed for page content, and needs
- * to be consistent with the site's configured
- * language. It might be part of a page title,
- * or a link, or text that will go into the
- * parser cache and be served back to other
- * visitors.
- */
- $cache = &$wgMessageCache;
- $lang = &$wgContLang;
- } else {
- /**
- * Message is for display purposes only.
- * The user may have selected a conversion-based
- * language variant or a separate user interface
- * language; if so use that.
- */
- if ( is_object( $wgContLang ) ) {
- if( in_array( $wgLanguageCode, $wgContLang->getVariants() ) ) {
- $cache = &$wgMessageCache;
- $lang = &$wgLang;
- } else {
- $cache = false;
- $lang = &$wgLang;
- }
+ if( is_object( $wgMessageCache ) ) {
+ $message = $wgMessageCache->get( $key, $useDB, $forContent );
+ }
+ else {
+ if( $forContent ) {
+ $lang = &$wgContLang;
} else {
- $cache = false;
- $lang = false;
+ $lang = &$wgLang;
}
- }
-
- if( is_object( $cache ) ) {
- $message = $cache->get( $key, $useDB, $forContent );
- } else {
- if ( !is_object( $lang ) ) {
- $lang = new Language;
- }
-
wfSuppressWarnings();
$message = $lang->getMessage( $key );
wfRestoreWarnings();
wfProfileOut( $fname.'-User' );
wfProfileIn( $fname.'-language2' );
-function setupLangObj(&$langclass, $langcode) {
+function setupLangObj(&$langclass) {
global $wgUseLatin1, $IP;
-
if( ! class_exists( $langclass ) ) {
- # Default to English/UTF-8
- require_once( "$IP/languages/LanguageUtf8.php" );
- $langclass = 'LanguageUtf8';
+ # Default to English/UTF-8, or for non-UTF-8, to latin-1
+ $baseclass = 'LanguageUtf8';
+ if( $wgUseLatin1 )
+ $baseclass = 'LanguageLatin1';
+ require_once( "$IP/languages/$baseclass.php" );
+ $lc = strtolower(substr($langclass, 8));
+ $snip = "
+ class $langclass extends $baseclass {
+ function getVariants() {
+ return array(\"$lc\");
+ }
+
+ }";
+
+ eval($snip);
}
$lang = new $langclass();
- if ( !is_object($lang) ) {
- print "No language class ($wgLang)\N";
- }
- if( $wgUseLatin1 ) {
- # For non-UTF-8 latin-1 downconversion
- require_once( "$IP/languages/LanguageLatin1.php" );
- $xxx = new LanguageLatin1( $lang );
- unset( $lang );
- $lang = $xxx;
- }
return $lang;
}
$wgContLanguageCode = $wgLanguageCode;
$wgContLangClass = 'Language' . str_replace( '-', '_', ucfirst( $wgContLanguageCode ) );
-$wgContLang = setupLangObj( $wgContLangClass, $wgContLangClass );
-$n = get_class($wgContLang);
+$wgContLang = setupLangObj( $wgContLangClass );
// set default user option from content language
if( !$wgUser->mDataLoaded ) {
if( $wgLangClass == $wgContLangClass ) {
$wgLang = &$wgContLang;
} else {
- require_once("$IP/languages/$wgLangClass.php");
- $wgLang = setupLangObj( $wgLangClass, $wgLanguageCode );
-}
+ wfSuppressWarnings();
+ include_once("$IP/languages/$wgLangClass.php");
+ wfRestoreWarnings();
+ $wgLang = setupLangObj( $wgLangClass );
+}
wfProfileOut( $fname.'-language' );
wfProfileIn( $fname.'-MessageCache' );
global $wgLanguageCode, $wgContLanguageCode, $wgContLang;
global $wgUseDatabaseMessages;
- if($wgLanguageCode != $wgContLanguageCode &&
- !in_array($wgLanguageCode, $wgContLang->getVariants())) {
- $err = wfMsg('allmessagesnotsupportedUI', $wgLanguageCode);
- $wgOut->addHTML( $err );
- return;
- }
if(!$wgUseDatabaseMessages) {
$wgOut->addHTML(wfMsg('allmessagesnotsupportedDB'));
return;
*
*/
function makeHTMLText( $messages ) {
- global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode;
+ global $wgLang, $wgUser, $wgLanguageCode, $wgContLanguageCode, $wgContLang;
$fname = "makeHTMLText";
wfProfileIn( $fname );
wfProfileOut( "$fname-check" );
wfProfileIn( "$fname-output" );
+
foreach( $messages as $key => $m ) {
$title = $wgLang->ucfirst( $key );
if($wgLanguageCode != $wgContLanguageCode)
$title.="/$wgLanguageCode";
+
$titleObj =& Title::makeTitle( NS_MEDIAWIKI, $title );
$talkPage =& Title::makeTitle( NS_MEDIAWIKI_TALK, $title );
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
global $wgAllowRealName, $wgImageLimits;
global $wgLanguageNames, $wgDisableLangConversion;
-
+ global $wgContLanguageCode;
$wgOut->setPageTitle( wfMsg( 'preferences' ) );
$wgOut->setArticleRelated( false );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
global $IP;
/* only add languages that have a file */
$langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
- if(file_exists($langfile)) {
+ if(file_exists($langfile) || $code == $wgContLanguageCode) {
$sel = ($code == $this->mUserLanguage)? 'selected="selected"' : '';
$wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
}
// utf8 if the language does not have a language file)
$v = $this->getVariants();
if( !empty( $v ) ) {
- foreach ($v as $v2) {
- if($v2 != 'utf8') {
- $lang = $v2;
- break;
- }
- }
+ return $v[0];
}
if($lang != '')
return $lang;
// get it from the class name
$lang = strtolower( substr( get_class( $this ), 8 ) );
- if($lang == 'utf8')
- $lang = 'en';
+
return $lang;
}
global $IP;
# overwrite language conversion option so that all variants
- # of the selected language are initialised
+ # of the messages are initialised
$wgDisableLangConversion = false;
if ( $messageArray ) {
ksort( $sortedArray );
$messages=array();
- /* check special case where the language does
- not have a language file
- */
- if( get_class($wgContLang) != 'language'.strtolower($wgContLanguageCode) ) {
+ $variants = $wgContLang->getVariants();
+ if(!in_array($wgContLanguageCode, $variants))
+ $variants[]=$wgContLanguageCode;
+
+ foreach ($variants as $v) {
+ $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) );
+ if( !class_exists($langclass) ) {
+ die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?");
+ }
+ $lang = new $langclass;
+
+ if($v==$wgContLanguageCode)
+ $suffix='';
+ else
+ $suffix="/$v";
foreach ($sortedArray as $key => $msg) {
- $messages[$key] = $wgContLang->getMessage($key);
+ $messages[$key.$suffix] = $lang->getMessage($key);
}
}
- else {
- $variants = $wgContLang->getVariants();
- if(!in_array($wgContLanguageCode, $variants))
- $variants[]=$wgContLanguageCode;
-
- foreach ($variants as $v) {
- $langclass = 'Language'. str_replace( '-', '_', ucfirst( $v ) );
- if( !class_exists($langclass) ) {
- die ("class $langclass not defined. perhaps you need to include the file $langclass.php in $wgContLangClass.php?");
- }
- $lang = new $langclass;
-
- if($v==$wgContLanguageCode)
- $suffix='';
- else
- $suffix="/$v";
- foreach ($sortedArray as $key => $msg) {
- $messages[$key.$suffix] = $lang->getMessage($key);
- }
- }
- }
initialiseMessagesReal( $overwrite, $messages );
}