Debian Codegraph @

skins/Vector/includes/Services/LanguageService.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Skins\Vector\Services;
4
5 class LanguageService {
6 /**
7 * The list of language codes for those languages that the search autocomplete widget cannot
8 * split a word on a Unicode code point followed by one or many combining marks (also code
9 * points).
10 *
11 * This list was compiled by [@TJones](https://phabricator.wikimedia.org/p/TJones/) as part
12 * of [T281797](https://phabricator.wikimedia.org/T281797).
13 *
14 * @var string[]
15 */
16 private $splittableLanguages;
17
18 public function __construct() {
19 $this->splittableLanguages = [
20 'ar', 'ary', 'arz', 'ckb', 'fa', 'glk', 'ks', 'mzn', 'pnb', 'ps', 'sd', 'skr', 'ug', 'ur',
21 'as', 'bn', 'bpy',
22 'awa', 'bh', 'dty', 'gom', 'hi', 'ks', 'mai', 'mr', 'ne', 'new', 'pi', 'sa',
23 'gu',
24 'pa',
25 'kn', 'tcy',
26 'km',
27 'ml',
28 'or',
29 'si',
30 'ta',
31 'te',
32 ];
33 }
34
35 /**
36 * Gets whether or not we can split words arbitrarily, for example when highlighting the user's query in the search
37 * autocomplete widget.
38 *
39 * @param string $code
40 * @return bool
41 */
42 public function canWordsBeSplitSafely( string $code ): bool {
43 return !in_array( $code, $this->splittableLanguages );
44 }
45 }