mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-14 11:15:33 +00:00
445ba883a2
Following on from I551414b1, disable query highlighting for the list of languages provided by @TJones in T281797. The user's interface language can be different from the wiki's content language and so the former is not available at configuration time. Thus, we fetch the user's interface language at request time. Fortunately, @TJones' list of languages is small so there should be little perceivable performance impact from the perpective of the user. Additional changes: - Remove the config.VectorWvuiSearchOptions.value.highlightQuery property from skin.json Bug: T281797 Change-Id: Ib39736a93fa64e82253f88551d125413e672558b
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Vector\Services;
|
|
|
|
class LanguageService {
|
|
/**
|
|
* The list of language codes for those languages that the search autocomplete widget cannot
|
|
* split a word on a Unicode code point followed by one or many combining marks (also code
|
|
* points).
|
|
*
|
|
* This list was compiled by [@TJones](https://phabricator.wikimedia.org/p/TJones/) as part
|
|
* of [T281797](https://phabricator.wikimedia.org/T281797).
|
|
*
|
|
* @var string[]
|
|
*/
|
|
private $splittableLanguages;
|
|
|
|
public function __construct() {
|
|
$this->splittableLanguages = [
|
|
'ar', 'ary', 'arz', 'ckb', 'fa', 'glk', 'ks', 'mzn', 'pnb', 'ps', 'sd', 'skr', 'ug', 'ur',
|
|
'as', 'bn', 'bpy',
|
|
'awa', 'bh', 'dty', 'gom', 'hi', 'ks', 'mai', 'mr', 'ne', 'new', 'pi', 'sa',
|
|
'gu',
|
|
'pa',
|
|
'kn', 'tcy',
|
|
'km',
|
|
'ml',
|
|
'or',
|
|
'si',
|
|
'ta',
|
|
'te',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Gets whether or not we can split words arbitrarily, for example when highlighting the user's query in the search
|
|
* autocomplete widget.
|
|
*
|
|
* @param string $code
|
|
* @return bool
|
|
*/
|
|
public function canWordsBeSplitSafely( string $code ): bool {
|
|
return !in_array( $code, $this->splittableLanguages );
|
|
}
|
|
}
|