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

Change subject: Fix incorrect behavior with non-capitalized namespace
......................................................................


Fix incorrect behavior with non-capitalized namespace

The code was unconditionally capitalizing the first letter.
Now using Title::capitalize() instead.

This code can be simplified further, as there is no proof
that the optimizations here significantly improve performance.

Change-Id: I2e8545ceb40385d9d4e9b709c46c8b7348d5773a
---
M TranslateUtils.php
1 file changed, 4 insertions(+), 5 deletions(-)

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



diff --git a/TranslateUtils.php b/TranslateUtils.php
index 27b7dec..88d1e09 100644
--- a/TranslateUtils.php
+++ b/TranslateUtils.php
@@ -17,16 +17,15 @@
         * database.
         * @param string $message Name of the message
         * @param string $code Language code in lower case and with dash as 
delimieter
+        * @param int $ns Namespace constant
         * @return string The normalised title as a string.
         */
-       public static function title( $message, $code ) {
-               global $wgContLang;
-
+       public static function title( $message, $code, $ns = NS_MEDIAWIKI ) {
                // Cache some amount of titles for speed.
                static $cache = array();
 
                if ( !isset( $cache[$message] ) ) {
-                       $cache[$message] = $wgContLang->ucfirst( $message );
+                       $cache[$message] = Title::capitalize( $message );
                }
 
                if ( $code ) {
@@ -58,7 +57,7 @@
         * @return string|null The contents or null.
         */
        public static function getMessageContent( $key, $language, $namespace = 
NS_MEDIAWIKI ) {
-               $title = self::title( $key, $language );
+               $title = self::title( $key, $language, $namespace );
                $data = self::getContents( array( $title ), $namespace );
 
                return isset( $data[$title][0] ) ? $data[$title][0] : null;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2e8545ceb40385d9d4e9b709c46c8b7348d5773a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to