Merge "LanguageNameIndexer/Search: use unicode aware lowercasing"

This commit is contained in:
jenkins-bot
2016-08-08 07:06:57 +00:00
committed by Gerrit Code Review
5 changed files with 11 additions and 8 deletions

View File

@@ -37,7 +37,7 @@ class LanguageNameIndexer extends Maintenance {
foreach ( $languages as $sourceLanguage => $autonym ) {
$translations = LanguageNames::getNames( $sourceLanguage, 0, 2 );
foreach ( $translations as $targetLanguage => $translation ) {
$translation = strtolower( $translation );
$translation = mb_strtolower( $translation );
$bucket = LanguageNameSearch::getIndex( $translation );
$buckets[$bucket][$translation] = $targetLanguage;
}

View File

@@ -29,8 +29,11 @@ class LanguageNameSearch {
self::init();
}
// Use code's mb_strtolower compatibily code for MW < 1.27
$language = Language::factory( 'en' );
// @todo: Shouldn't this be unicode aware?
$searchKey = strtolower( $searchKey );
$searchKey = $language->lc( $searchKey );
$index = self::getIndex( $searchKey );
if ( !isset( self::$languagenames[$index] ) ) {

File diff suppressed because one or more lines are too long

View File

@@ -19,12 +19,12 @@
*/
require_once __DIR__ . '/../../data/LanguageNameSearch.php';
class LanguageSearchTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider searchDataProvider
*/
public function testSearch( $searchKey, $result ) {
$this->assertEquals( $result, LanguageNameSearch::search( $searchKey, 1 ) );
public function testSearch( $searchKey, $expected ) {
$actual = LanguageNameSearch::search( $searchKey, 1 );
$this->assertEquals( $expected, $actual );
}
public function searchDataProvider() {
@@ -40,7 +40,7 @@ class LanguageSearchTest extends PHPUnit_Framework_TestCase {
]
],
[ 'Φινλαν', [
'fi' => 'Φινλανδικά',
'fi' => 'φινλανδικά',
]
],
[ 'blah', []

View File

@@ -1,5 +1,5 @@
ifndef MW_INSTALL_PATH
MW_INSTALL_PATH=../../..
MW_INSTALL_PATH=../../../..
endif
default: