From c847ba5e1e6eda97e5661acae6a37e8cc896c2b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 26 Nov 2005 23:59:55 +0000 Subject: [PATCH] * Add wfMsgNoTrans() and wfMsgForContentNoTrans() to get untransformed messages --- includes/GlobalFunctions.php | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 72d0d80c54..52a0e3388e 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -287,6 +287,15 @@ function wfMsg( $key ) { return wfMsgReal( $key, $args, true ); } +/** + * Same as above except doesn't transform the message + */ +function wfMsgNoTrans( $key ) { + $args = func_get_args(); + array_shift( $args ); + return wfMsgReal( $key, $args, true, false ); +} + /** * Get a message from anywhere, for the current global language * set with $wgLanguageCode. @@ -320,6 +329,20 @@ function wfMsgForContent( $key ) { return wfMsgReal( $key, $args, true, $forcontent ); } +/** + * Same as above except doesn't transform the message + */ +function wfMsgForContentNoTrans( $key ) { + global $wgForceUIMsgAsContentMsg; + $args = func_get_args(); + array_shift( $args ); + $forcontent = true; + if( is_array( $wgForceUIMsgAsContentMsg ) && + in_array( $key, $wgForceUIMsgAsContentMsg ) ) + $forcontent = false; + return wfMsgReal( $key, $args, true, $forcontent, false ); +} + /** * Get a message from the language file, for the UI elements */ @@ -347,11 +370,11 @@ function wfMsgNoDBForContent( $key ) { /** * Really get a message */ -function wfMsgReal( $key, $args, $useDB, $forContent=false ) { +function wfMsgReal( $key, $args, $useDB, $forContent=false, $transform = true ) { $fname = 'wfMsgReal'; wfProfileIn( $fname ); - $message = wfMsgGetKey( $key, $useDB, $forContent ); + $message = wfMsgGetKey( $key, $useDB, $forContent, $transform ); $message = wfMsgReplaceArgs( $message, $args ); wfProfileOut( $fname ); return $message; @@ -365,12 +388,14 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false ) { * @return string * @access private */ -function wfMsgGetKey( $key, $useDB, $forContent = false ) { +function wfMsgGetKey( $key, $useDB, $forContent = false, $transform = true ) { global $wgParser, $wgMsgParserOptions; global $wgContLang, $wgLanguageCode; global $wgMessageCache, $wgLang; if( is_object( $wgMessageCache ) ) { + if ( ! $transform ) + $wgMessageCache->disableTransform(); $message = $wgMessageCache->get( $key, $useDB, $forContent ); } else { if( $forContent ) { @@ -389,7 +414,7 @@ function wfMsgGetKey( $key, $useDB, $forContent = false ) { wfRestoreWarnings(); if($message === false) $message = Language::getMessage($key); - if(strstr($message, '{{' ) !== false) { + if ( $transform && strstr( $message, '{{' ) !== false ) { $message = $wgParser->transformMsg($message, $wgMsgParserOptions); } } -- 2.20.1