Run parsemag stuff through the proper language when wfMsgExt() asks for a specific...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 13 Nov 2008 01:02:17 +0000 (01:02 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 13 Nov 2008 01:02:17 +0000 (01:02 +0000)
Previously we only passed on if we were interface or content, but if we're rendering for some third alternative it didn't get used.
Note that parse and parseinline are probably still wrong.... some better model may be required here.
Also it may be wrong in the case of fallbacks ... if you get an English message, is it right to use the Czech magic word parsing?
Hmm.
Might back it out if there's a better way. :)

includes/GlobalFunctions.php
includes/MessageCache.php

index eaa806c..d8b8fd0 100644 (file)
@@ -731,7 +731,9 @@ function wfMsgExt( $key, $options ) {
        } elseif ( in_array('parsemag', $options) ) {
                global $wgMessageCache;
                if ( isset( $wgMessageCache ) ) {
-                       $string = $wgMessageCache->transform( $string, !$forContent );
+                       $string = $wgMessageCache->transform( $string,
+                               !$forContent,
+                               is_object( $langCode ) ? $langCode : null );
                }
        }
 
index 2721708..a06b0cb 100644 (file)
@@ -647,7 +647,7 @@ class MessageCache {
                return $message;
        }
 
-       function transform( $message, $interface = false ) {
+       function transform( $message, $interface = false, $language = null ) {
                // Avoid creating parser if nothing to transfrom
                if( strpos( $message, '{{' ) === false ) {
                        return $message;
@@ -670,6 +670,7 @@ class MessageCache {
                if ( $this->mParser ) {
                        $popts = $this->getParserOptions();
                        $popts->setInterfaceMessage( $interface );
+                       $popts->setTargetLanguage( $language );
                        $message = $this->mParser->transformMsg( $message, $popts );
                }
                return $message;