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

Change subject: [WIP] Add aliases for Georgian, Armenian, Spanish, and Japanese
......................................................................

[WIP] Add aliases for Georgian, Armenian, Spanish, and Japanese

Also make it possible to add multiple aliases for a language.

Bug: T178996

Change-Id: I00bb4a158caed0c1ba15d41e294281a001c917b1
---
M data/LanguageNameIndexer.php
M tests/phpunit/LanguageSearchTest.php
2 files changed, 36 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/99/404799/1

diff --git a/data/LanguageNameIndexer.php b/data/LanguageNameIndexer.php
index 30f4ca9..113c2a1 100644
--- a/data/LanguageNameIndexer.php
+++ b/data/LanguageNameIndexer.php
@@ -76,20 +76,28 @@
                // To resolve this, some languages are added here locally.
                $specialLanguages = [
                        // Catalan, sometimes searched as "Valencià"
-                       'ca' => 'valencia',
+                       'ca' => [ 'valencia' ],
+                       // Spanish, the transliteration of the autonym is often 
used for searching
+                       'es' => [ 'castellano' ],
+                       // Armenian, the transliteration of the autonym is 
often used for searching
+                       'hy' => [ 'hayeren' ],
                        // Georgian, the transliteration of the autonym is 
often used for searching
-                       'ka' => 'kartuli',
+                       'ka' => [ 'kartuli', 'qartuli' ],
+                       // Japanese, the transliteration of the autonym is 
often used for searching
+                       'ja' => [ 'nihongo', 'にほんご' ],
                        // Western Punjabi, doesn't start with the word 
"Punjabi" in any language
-                       'pnb' => 'punjabi western',
+                       'pnb' => [ 'punjabi western' ],
                        // Simplified and Traditional Chinese, because zh-hans 
and zh-hant
                        // are not mapped to any English name
-                       'zh-hans' => 'chinese simplified',
-                       'zh-hant' => 'chinese traditional',
+                       'zh-hans' => [ 'chinese simplified' ],
+                       'zh-hant' => [ 'chinese traditional' ],
                ];
 
-               foreach ( $specialLanguages as $targetLanguage => $translation 
) {
-                       $bucket = LanguageNameSearch::getIndex( $translation );
-                       $buckets[$bucket]['prefix'][$translation] = 
$targetLanguage;
+               foreach ( $specialLanguages as $targetLanguage => $translations 
) {
+                       foreach ( $translations as $translation ) {
+                               $bucket = LanguageNameSearch::getIndex( 
$translation );
+                               $buckets[$bucket]['prefix'][$translation] = 
$targetLanguage;
+                       }
                }
 
                $lengths = [];
diff --git a/tests/phpunit/LanguageSearchTest.php 
b/tests/phpunit/LanguageSearchTest.php
index 1d86d5c..6e21265 100644
--- a/tests/phpunit/LanguageSearchTest.php
+++ b/tests/phpunit/LanguageSearchTest.php
@@ -67,10 +67,30 @@
                                'pnb' => 'punjabi western',
                        ]
                        ],
+                       [ 'castellano', [
+                               'es' => 'castellano',
+                       ]
+                       ],
+                       [ 'hayeren', [
+                               'hy' => 'hayeren',
+                       ]
+                       ],
                        [ 'kartuli', [
                                'ka' => 'kartuli',
                        ]
                        ],
+                       [ 'qartuli', [
+                               'ka' => 'kartuli',
+                       ]
+                       ],
+                       [ 'nihongo', [
+                               'ja' => 'nihongo',
+                       ]
+                       ],
+                       [ 'にほんご', [
+                               'ja' => 'にほんご',
+                       ]
+                       ],
                        [ 'valencia', [
                                'ca' => 'valencia',
                        ]

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I00bb4a158caed0c1ba15d41e294281a001c917b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>

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

Reply via email to