jenkins-bot has submitted this change and it was merged.

Change subject: Make msg method of DerivativeContext work properly.
......................................................................


Make msg method of DerivativeContext work properly.

Previously, the msg method was not taking into account any
changes to the context, and was just using the original context.

For example, if you had a DerivativeContext object, where the
original context had a language of en, and then you did
$derivContext->setLanguage( 'fr' );, $derivContext->msg( 'foo' )
was still outputting stuff in english instead of french.

Change-Id: I4a87e0e2664e77bf79a80c873db384e0c3f607e7
---
M includes/context/DerivativeContext.php
1 file changed, 16 insertions(+), 0 deletions(-)

Approvals:
  IAlex: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/context/DerivativeContext.php 
b/includes/context/DerivativeContext.php
index eda56a7..d4caf05 100644
--- a/includes/context/DerivativeContext.php
+++ b/includes/context/DerivativeContext.php
@@ -281,4 +281,20 @@
                        return $this->getContext()->getSkin();
                }
        }
+
+       /**
+        * Get a message using the current context.
+        *
+        * This can't just inherit from ContextSource, since then
+        * it would set only the original context, and not take
+        * into account any changes.
+        *
+        * @param String Message name
+        * @param Variable number of message arguments
+        * @return Message
+        */
+       public function msg() {
+               $args = func_get_args();
+               return call_user_func_array( 'wfMessage', $args )->setContext( 
$this );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/78837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a87e0e2664e77bf79a80c873db384e0c3f607e7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Daniel Friesen <dan...@nadir-seen-fire.com>
Gerrit-Reviewer: IAlex <coderev...@emsenhuber.ch>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to