Improve ULS language search api

* Store prefixes and infixes separately in the data
* First match language code, then prefixes, then infixes
* Try to use suggestion either in user language or autonym first
* use formatversion=2 to avoid escaping Unicode

Using Language::fetchLanguageName might can have a small
performance impact. On the other hand there is now check
to skip languages we already found, avoiding some fuzzy
matching.

This is in a preparation for a change in jquery.uls to use
the search API more, while trying to reduce the amount of
weird autocompletion suggestions we show to the user.

Bug: T73891
Change-Id: Id94c5352d9a591969bf90144d1d2d5e758d08301
This commit is contained in:
Niklas Laxström
2017-11-27 12:22:25 +01:00
parent a353c5ab65
commit e87dd20cdd
6 changed files with 51632 additions and 46567 deletions

View File

@@ -23,7 +23,7 @@
// MediaWiki overrides for ULS defaults
$.fn.uls.defaults = $.extend( $.fn.uls.defaults, {
languages: mw.config.get( 'wgULSLanguages' ) || {},
searchAPI: mw.util.wikiScript( 'api' ) + '?action=languagesearch&format=json'
searchAPI: mw.util.wikiScript( 'api' ) + '?action=languagesearch&format=json&formatversion=2'
} );
// No need of IME in the ULS language search bar