TTO has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/329733 )

Change subject: Correct categorization of 'pt-br' and similar language codes
......................................................................

Correct categorization of 'pt-br' and similar language codes

wfBCP47 can return language codes like 'pt-BR' and 'shi-Latn', whereas
MediaWiki uses only lowercase for its codes ('pt-br', 'shi-latn'). When
looking up the language names, we need to make sure we use normalized
lowercase codes.

Also avoid ever placing pages in illegally-titled categories, by using
Title::makeTitleSafe to ensure normalization of the category name.

Bug: T146778
Change-Id: I16059db9d1f2060a760223cc9c4488a988a04475
---
M BabelBox/LanguageBabelBox.php
M BabelLanguageCodes.class.php
2 files changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Babel 
refs/changes/33/329733/1

diff --git a/BabelBox/LanguageBabelBox.php b/BabelBox/LanguageBabelBox.php
index d2f5edc..bebf8f7 100644
--- a/BabelBox/LanguageBabelBox.php
+++ b/BabelBox/LanguageBabelBox.php
@@ -214,7 +214,7 @@
                ] );
 
                // Normalize using Title
-               return Title::makeTitle( NS_CATEGORY, $category )->getDBkey();
+               return Title::makeTitleSafe( NS_CATEGORY, $category 
)->getDBkey();
        }
 
 }
diff --git a/BabelLanguageCodes.class.php b/BabelLanguageCodes.class.php
index 9dffeaf..fcfb6c5 100644
--- a/BabelLanguageCodes.class.php
+++ b/BabelLanguageCodes.class.php
@@ -21,6 +21,8 @@
         * @return string|bool Language code, or false for invalid language 
code.
         */
        public static function getCode( $code ) {
+               $code = strtolower( $code );
+
                $mediawiki = Language::fetchLanguageName( $code );
                if ( $mediawiki !== '' ) {
                        return $code;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I16059db9d1f2060a760223cc9c4488a988a04475
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Babel
Gerrit-Branch: master
Gerrit-Owner: TTO <at.li...@live.com.au>

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

Reply via email to