$wgTotalEdits = -1;
-/**
- * in "zh", whether conversion of messages should take place
- */
-$wgDoZhMessageConversion = true;
-
require_once( 'DatabaseFunctions.php' );
require_once( 'UpdateClasses.php' );
require_once( 'LogPage.php' );
$wgReplacementKeys = array( '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9' );
/**
- * Get a message from anywhere
+ * Get a message from anywhere, for the UI elements
*/
function wfMsg( $key ) {
global $wgRequest;
+
if ( $wgRequest->getVal( 'debugmsg' ) ) {
if ( $key == 'linktrail' /* a special case where we want to return something specific */ )
return "/^()(.*)$/sD";
}
/**
- * Get a message from the language file
+ * Get a message from anywhere, for the content
+ */
+function wfMsgForContent( $key ) {
+ global $wgRequest;
+ if ( $wgRequest->getVal( 'debugmsg' ) ) {
+ if ( $key == 'linktrail' /* a special case where we want to return something specific */ )
+ return "/^()(.*)$/sD";
+ else
+ return $key;
+ }
+ $args = func_get_args();
+ if ( count( $args ) ) {
+ array_shift( $args );
+ }
+ return wfMsgReal( $key, $args, true, true );
+
+
+}
+
+/**
+ * Get a message from the language file, for the UI elements
*/
function wfMsgNoDB( $key ) {
$args = func_get_args();
return wfMsgReal( $key, $args, false );
}
+/**
+ * Get a message from the language file, for the content
+ */
+function wfMsgNoDBForContent( $key ) {
+
+ $args = func_get_args();
+ if ( count( $args ) ) {
+ array_shift( $args );
+ }
+ return wfMsgReal( $key, $args, false, true );
+}
+
+
/**
* Really get a message
*/
-function wfMsgReal( $key, $args, $useDB ) {
- global $wgReplacementKeys, $wgMessageCache, $wgLang, $wgLanguageCode;
- global $wgDoZhMessageConversion;
+function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
+ global $wgReplacementKeys, $wgParser, $wgMsgParserOptions;
+ global $wgContLang, $wgLanguageCode;
+ if($forContent) {
+ global $wgMessageCache;
+ $cache = &$wgMessageCache;
+ $lang = &$wgContLang;
+ }
+ else {
+ if(in_array($wgLanguageCode, $wgContLang->getVariants())){
+ global $wgLang, $wgMessageCache;
+ $cache = &$wgMessageCache;
+ $lang = $wgLang;
+ }
+ else {
+ global $wgLang;
+ $cache = false;
+ $lang = &$wgLang;
+ }
+ }
+
$fname = 'wfMsg';
wfProfileIn( $fname );
- if ( $wgMessageCache ) {
- $message = $wgMessageCache->get( $key, $useDB );
- } elseif ( $wgLang ) {
- $message = $wgLang->getMessage( $key );
+ if ( is_object($cache) ) {
+ $message = $cache->get( $key, $useDB, $forContent );
+ } elseif (is_object($lang)) {
+ $message = $lang->getMessage( $key );
+ if(!$message)
+ $message = Language::getMessage($key);
+ if(strstr($message, '{{' ) !== false) {
+ $message = $wgParser->transformMsg($message, $wgMsgParserOptions);
+ }
} else {
wfDebug( "No language object when getting $key\n" );
$message = "<$key>";
}
- if(strtolower($wgLanguageCode) == "zh" && $wgDoZhMessageConversion) {
- $message = $wgLang->convert($message);
- }
# Replace arguments
if( count( $args ) ) {
$message = str_replace( $wgReplacementKeys, $args, $message );