Merge "LanguageNameIndexer/Search: use unicode aware lowercasing"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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', []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
ifndef MW_INSTALL_PATH
|
||||
MW_INSTALL_PATH=../../..
|
||||
MW_INSTALL_PATH=../../../..
|
||||
endif
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user