Nikerabbit has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75835


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/35/75835/1

diff --git a/TranslateUtils.php b/TranslateUtils.php
index 27b7dec..209e530 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
+        * @paran 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: newchange
Gerrit-Change-Id: I2e8545ceb40385d9d4e9b709c46c8b7348d5773a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>

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

Reply via email to