MediaWiki  master
IcuCollation.php
Go to the documentation of this file.
1 <?php
22 
26 class IcuCollation extends Collation {
27  private const FIRST_LETTER_VERSION = 4;
28 
31 
33  private $mainCollator;
34 
36  private $locale;
37 
40 
42  private $useNumericCollation = false;
43 
46 
56  private const CJK_BLOCKS = [
57  [ 0x2E80, 0x2EFF ], // CJK Radicals Supplement
58  [ 0x2F00, 0x2FDF ], // Kangxi Radicals
59  [ 0x2FF0, 0x2FFF ], // Ideographic Description Characters
60  [ 0x3000, 0x303F ], // CJK Symbols and Punctuation
61  [ 0x31C0, 0x31EF ], // CJK Strokes
62  [ 0x3200, 0x32FF ], // Enclosed CJK Letters and Months
63  [ 0x3300, 0x33FF ], // CJK Compatibility
64  [ 0x3400, 0x4DBF ], // CJK Unified Ideographs Extension A
65  [ 0x4E00, 0x9FFF ], // CJK Unified Ideographs
66  [ 0xF900, 0xFAFF ], // CJK Compatibility Ideographs
67  [ 0xFE30, 0xFE4F ], // CJK Compatibility Forms
68  [ 0x20000, 0x2A6DF ], // CJK Unified Ideographs Extension B
69  [ 0x2A700, 0x2B73F ], // CJK Unified Ideographs Extension C
70  [ 0x2B740, 0x2B81F ], // CJK Unified Ideographs Extension D
71  [ 0x2F800, 0x2FA1F ], // CJK Compatibility Ideographs Supplement
72  ];
73 
95  private const TAILORING_FIRST_LETTERS = [
96  'af' => [],
97  'am' => [],
98  'ar' => [],
99  'as' => [ "\u{0982}", "\u{0981}", "\u{0983}", "\u{09CE}", "ক্ষ " ],
100  'ast' => [ "Ch", "Ll", "Ñ" ], // not in libicu
101  'az' => [ "Ç", "Ə", "Ğ", "İ", "Ö", "Ş", "Ü" ],
102  'be' => [ "Ё" ],
103  'be-tarask' => [ "Ё" ],
104  'bg' => [],
105  'bn' => [ 'ং', 'ঃ', 'ঁ' ],
106  'bn@collation=traditional' => [
107  'ং', 'ঃ', 'ঁ', 'ক্', 'খ্', 'গ্', 'ঘ্', 'ঙ্', 'চ্', 'ছ্', 'জ্', 'ঝ্',
108  'ঞ্', 'ট্', 'ঠ্', 'ড্', 'ঢ্', 'ণ্', 'ৎ', 'থ্', 'দ্', 'ধ্', 'ন্', 'প্',
109  'ফ্', 'ব্', 'ভ্', 'ম্', 'য্', 'র্', 'ৰ্', 'ল্', 'ৱ্', 'শ্', 'ষ্', 'স্', 'হ্'
110  ],
111  'bo' => [],
112  'br' => [ "Ch", "C'h" ],
113  'bs' => [ "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ],
114  'bs-Cyrl' => [],
115  'ca' => [],
116  'chr' => [],
117  'co' => [], // not in libicu
118  'cs' => [ "Č", "Ch", "Ř", "Š", "Ž" ],
119  'cy' => [ "Ch", "Dd", "Ff", "Ng", "Ll", "Ph", "Rh", "Th" ],
120  'da' => [ "Æ", "Ø", "Å" ],
121  'de' => [],
122  'de-AT@collation=phonebook' => [ 'ä', 'ö', 'ü', 'ß' ],
123  'dsb' => [ "Č", "Ć", "Dź", "Ě", "Ch", "Ł", "Ń", "Ŕ", "Š", "Ś", "Ž", "Ź" ],
124  'ee' => [ "Dz", "Ɖ", "Ɛ", "Ƒ", "Gb", "Ɣ", "Kp", "Ny", "Ŋ", "Ɔ", "Ts", "Ʋ" ],
125  'el' => [],
126  'en' => [],
127  'eo' => [ "Ĉ", "Ĝ", "Ĥ", "Ĵ", "Ŝ", "Ŭ" ],
128  'es' => [ "Ñ" ],
129  'et' => [ "Š", "Ž", "Õ", "Ä", "Ö", "Ü" ],
130  'eu' => [ "Ñ" ], // not in libicu
131  'fa' => [
132  // RTL, let's put each letter on a new line
133  "آ",
134  "ء",
135  "ه",
136  "ا",
137  "و"
138  ],
139  'fi' => [ "Å", "Ä", "Ö" ],
140  'fil' => [ "Ñ", "Ng" ],
141  'fo' => [ "Á", "Ð", "Í", "Ó", "Ú", "Ý", "Æ", "Ø", "Å" ],
142  'fr' => [],
143  'fr-CA' => [], // fr-CA sorts accents slightly different from fr.
144  'fur' => [ "À", "Á", "Â", "È", "Ì", "Ò", "Ù" ], // not in libicu
145  'fy' => [], // not in libicu
146  'ga' => [],
147  'gd' => [], // not in libicu
148  'gl' => [ "Ch", "Ll", "Ñ" ],
149  'gu' => [ "\u{0A82}", "\u{0A83}", "\u{0A81}", "\u{0AB3}" ],
150  'ha' => [ 'Ɓ', 'Ɗ', 'Ƙ', 'Sh', 'Ts', 'Ƴ' ],
151  'haw' => [ 'ʻ' ],
152  'he' => [],
153  'hi' => [ "\u{0902}", "\u{0903}" ],
154  'hr' => [ "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ],
155  'hsb' => [ "Č", "Dź", "Ě", "Ch", "Ł", "Ń", "Ř", "Š", "Ć", "Ž" ],
156  'hu' => [ "Cs", "Dz", "Dzs", "Gy", "Ly", "Ny", "Ö", "Sz", "Ty", "Ü", "Zs" ],
157  'hy' => [ "և" ],
158  'id' => [],
159  'ig' => [ "Ch", "Gb", "Gh", "Gw", "Ị", "Kp", "Kw", "Ṅ", "Nw", "Ny", "Ọ", "Sh", "Ụ" ],
160  'is' => [ "Á", "Ð", "É", "Í", "Ó", "Ú", "Ý", "Þ", "Æ", "Ö", "Å" ],
161  'it' => [],
162  'ka' => [],
163  'kk' => [ "Ү", "І" ],
164  'kl' => [ "Æ", "Ø", "Å" ],
165  'km' => [
166  "រ", "ឫ", "ឬ", "ល", "ឭ", "ឮ", "\u{17BB}\u{17C6}",
167  "\u{17C6}", "\u{17B6}\u{17C6}", "\u{17C7}",
168  "\u{17B7}\u{17C7}", "\u{17BB}\u{17C7}",
169  "\u{17C1}\u{17C7}", "\u{17C4}\u{17C7}",
170  ],
171  'kn' => [ "\u{0C81}", "\u{0C83}", "\u{0CF1}", "\u{0CF2}" ],
172  'kok' => [ "\u{0902}", "\u{0903}", "ळ", "क्ष" ],
173  'ku' => [ "Ç", "Ê", "Î", "Ş", "Û" ], // not in libicu
174  'ky' => [ "Ё" ],
175  'la' => [], // not in libicu
176  'lb' => [],
177  'lkt' => [ 'Č', 'Ǧ', 'Ȟ', 'Š', 'Ž' ],
178  'ln' => [ 'Ɛ' ],
179  'lo' => [],
180  'lt' => [ "Č", "Š", "Ž" ],
181  'lv' => [ "Č", "Ģ", "Ķ", "Ļ", "Ņ", "Š", "Ž" ],
182  'mk' => [ "Ѓ", "Ќ" ],
183  'ml' => [],
184  'mn' => [],
185  'mo' => [ "Ă", "Â", "Î", "Ș", "Ț" ], // not in libicu
186  'mr' => [ "\u{0902}", "\u{0903}", "ळ", "क्ष", "ज्ञ" ],
187  'ms' => [],
188  'mt' => [ "Ċ", "Ġ", "Għ", "Ħ", "Ż" ],
189  'nb' => [ "Æ", "Ø", "Å" ],
190  'ne' => [],
191  'nl' => [],
192  'nn' => [ "Æ", "Ø", "Å" ],
193  'no' => [ "Æ", "Ø", "Å" ], // not in libicu. You should probably use nb or nn instead.
194  'oc' => [], // not in libicu
195  'om' => [ 'Ch', 'Dh', 'Kh', 'Ny', 'Ph', 'Sh' ],
196  'or' => [ "\u{0B01}", "\u{0B02}", "\u{0B03}", "କ୍ଷ" ],
197  'pa' => [ "\u{0A4D}" ],
198  'pl' => [ "Ą", "Ć", "Ę", "Ł", "Ń", "Ó", "Ś", "Ź", "Ż" ],
199  'pt' => [],
200  'rm' => [], // not in libicu
201  'ro' => [ "Ă", "Â", "Î", "Ș", "Ț" ],
202  'ru' => [],
203  'rup' => [ "Ă", "Â", "Î", "Ľ", "Ń", "Ș", "Ț" ], // not in libicu
204  'sco' => [],
205  'se' => [
206  'Á', 'Č', 'Ʒ', 'Ǯ', 'Đ', 'Ǧ', 'Ǥ', 'Ǩ', 'Ŋ',
207  'Š', 'Ŧ', 'Ž', 'Ø', 'Æ', 'Ȧ', 'Ä', 'Ö'
208  ],
209  'si' => [ "\u{0D82}", "\u{0D83}", "\u{0DA4}" ],
210  'sk' => [ "Ä", "Č", "Ch", "Ô", "Š", "Ž" ],
211  'sl' => [ "Č", "Š", "Ž" ],
212  'smn' => [ "Á", "Č", "Đ", "Ŋ", "Š", "Ŧ", "Ž", "Æ", "Ø", "Å", "Ä", "Ö" ],
213  'sq' => [ "Ç", "Dh", "Ë", "Gj", "Ll", "Nj", "Rr", "Sh", "Th", "Xh", "Zh" ],
214  'sr' => [],
215  'sr-Latn' => [ "Č", "Ć", "Dž", "Đ", "Lj", "Nj", "Š", "Ž" ],
216  'sv' => [ "Å", "Ä", "Ö" ],
217  'sv@collation=standard' => [ "Å", "Ä", "Ö" ],
218  'sw' => [],
219  'ta' => [
220  "\u{0B82}", "ஃ", "க்ஷ", "க்", "ங்", "ச்", "ஞ்", "ட்", "ண்", "த்", "ந்",
221  "ப்", "ம்", "ய்", "ர்", "ல்", "வ்", "ழ்", "ள்", "ற்", "ன்", "ஜ்", "ஶ்", "ஷ்",
222  "ஸ்", "ஹ்", "க்ஷ்"
223  ],
224  'te' => [ "\u{0C01}", "\u{0C02}", "\u{0C03}" ],
225  'th' => [ "ฯ", "\u{0E46}", "\u{0E4D}", "\u{0E3A}" ],
226  'tk' => [ "Ç", "Ä", "Ž", "Ň", "Ö", "Ş", "Ü", "Ý" ],
227  'tl' => [ "Ñ", "Ng" ], // not in libicu
228  'to' => [ "Ng", "ʻ" ],
229  'tr' => [ "Ç", "Ğ", "İ", "Ö", "Ş", "Ü" ],
230  '-tr' => [ "ı" ],
231  'tt' => [ "Ә", "Ө", "Ү", "Җ", "Ң", "Һ" ], // not in libicu
232  'uk' => [ "Ґ", "Ь" ],
233  'uz' => [ "Ch", "G'", "Ng", "O'", "Sh" ], // not in libicu
234  'vi' => [ "Ă", "Â", "Đ", "Ê", "Ô", "Ơ", "Ư" ],
235  'vo' => [ "Ä", "Ö", "Ü" ],
236  'yi' => [
237  "\u{05D1}\u{05BF}", "\u{05DB}\u{05BC}", "\u{05E4}\u{05BC}",
238  "\u{05E9}\u{05C2}", "\u{05EA}\u{05BC}"
239  ],
240  'yo' => [ "Ẹ", "Gb", "Ọ", "Ṣ" ],
241  'zu' => [],
242  ];
243 
248  public function __construct(
249  LanguageFactory $languageFactory,
250  $locale
251  ) {
252  $this->locale = $locale;
253  // Drop everything after the '@' in locale's name
254  $localeParts = explode( '@', $locale );
255  $this->digitTransformLanguage = $languageFactory->getLanguage( $locale === 'root' ? 'en' : $localeParts[0] );
256 
257  $this->mainCollator = Collator::create( $locale );
258  if ( !$this->mainCollator ) {
259  throw new MWException( "Invalid ICU locale specified for collation: $locale" );
260  }
261 
262  $this->primaryCollator = Collator::create( $locale );
263  $this->primaryCollator->setStrength( Collator::PRIMARY );
264 
265  // If the special suffix for numeric collation is present, turn on numeric collation.
266  if ( substr( $locale, -5, 5 ) === '-u-kn' ) {
267  $this->useNumericCollation = true;
268  // Strip off the special suffix so it doesn't trip up fetchFirstLetterData().
269  $this->locale = substr( $this->locale, 0, -5 );
270  $this->mainCollator->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON );
271  $this->primaryCollator->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON );
272  }
273  }
274 
275  public function getSortKey( $string ) {
276  return $this->mainCollator->getSortKey( $string );
277  }
278 
279  public function getPrimarySortKey( $string ) {
280  return $this->primaryCollator->getSortKey( $string );
281  }
282 
283  public function getFirstLetter( $string ) {
284  $string = strval( $string );
285  if ( $string === '' ) {
286  return '';
287  }
288 
289  $firstChar = mb_substr( $string, 0, 1, 'UTF-8' );
290 
291  // If the first character is a CJK character, just return that character.
292  if ( ord( $firstChar ) > 0x7f && self::isCjk( UtfNormal\Utils::utf8ToCodepoint( $firstChar ) ) ) {
293  return $firstChar;
294  }
295 
296  $sortKey = $this->getPrimarySortKey( $string );
297 
298  // Do a binary search to find the correct letter to sort under
300  [ $this, 'getSortKeyByLetterIndex' ],
301  $this->getFirstLetterCount(),
302  'strcmp',
303  $sortKey );
304 
305  if ( $min === false ) {
306  // Before the first letter
307  return '';
308  }
309 
310  $sortLetter = $this->getLetterByIndex( $min );
311 
312  if ( $this->useNumericCollation ) {
313  // If the sort letter is a number, return '0–9' (or localized equivalent).
314  // ASCII value of 0 is 48. ASCII value of 9 is 57.
315  // Note that this also applies to non-Arabic numerals since they are
316  // mapped to Arabic numeral sort letters. For example, ২ sorts as 2.
317  if ( ord( $sortLetter ) >= 48 && ord( $sortLetter ) <= 57 ) {
318  $sortLetter = wfMessage( 'category-header-numerals' )->numParams( 0, 9 )->text();
319  }
320  }
321  return $sortLetter;
322  }
323 
328  public function getFirstLetterData() {
329  if ( $this->firstLetterData === null ) {
331  $cacheKey = $cache->makeKey(
332  'first-letters',
333  static::class,
334  $this->locale,
335  $this->digitTransformLanguage->getCode(),
336  INTL_ICU_VERSION,
337  self::FIRST_LETTER_VERSION
338  );
339  $this->firstLetterData = $cache->getWithSetCallback( $cacheKey, $cache::TTL_WEEK, function () {
340  return $this->fetchFirstLetterData();
341  } );
342  }
343  return $this->firstLetterData;
344  }
345 
350  private function fetchFirstLetterData() {
351  global $IP;
352  // Generate data from serialized data file
353  if ( isset( self::TAILORING_FIRST_LETTERS[$this->locale] ) ) {
354  $letters = require "$IP/includes/collation/data/first-letters-root.php";
355  // Append additional characters
356  $letters = array_merge( $letters, self::TAILORING_FIRST_LETTERS[$this->locale] );
357  // Remove unnecessary ones, if any
358  if ( isset( self::TAILORING_FIRST_LETTERS['-' . $this->locale] ) ) {
359  $letters = array_diff( $letters, self::TAILORING_FIRST_LETTERS['-' . $this->locale] );
360  }
361  // Apply digit transforms
362  $digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
363  $letters = array_diff( $letters, $digits );
364  foreach ( $digits as $digit ) {
365  $letters[] = $this->digitTransformLanguage->formatNumNoSeparators( $digit );
366  }
367  } elseif ( $this->locale === 'root' ) {
368  $letters = require "$IP/includes/collation/data/first-letters-root.php";
369  } else {
370  // FIXME: Is this still used?
371  $letters = $this->getPrecompiledData( "first-letters-{$this->locale}.ser" );
372  if ( $letters === false ) {
373  throw new MWException( "MediaWiki does not support ICU locale " .
374  "\"{$this->locale}\"" );
375  }
376  }
377 
378  /* Sort the letters.
379  *
380  * It's impossible to have the precompiled data file properly sorted,
381  * because the sort order changes depending on ICU version. If the
382  * array is not properly sorted, the binary search will return random
383  * results.
384  *
385  * We also take this opportunity to remove primary collisions.
386  */
387  $letterMap = [];
388  foreach ( $letters as $letter ) {
389  $key = $this->getPrimarySortKey( $letter );
390  if ( isset( $letterMap[$key] ) ) {
391  // Primary collision (two characters with the same sort position).
392  // Keep whichever one sorts first in the main collator.
393  $comp = $this->mainCollator->compare( $letter, $letterMap[$key] );
394  wfDebug( "Primary collision '$letter' '{$letterMap[$key]}' (comparison: $comp)" );
395  // If that also has a collision, use codepoint as a tiebreaker.
396  if ( $comp === 0 ) {
397  $comp = UtfNormal\Utils::utf8ToCodepoint( $letter ) <=>
398  UtfNormal\Utils::utf8ToCodepoint( $letterMap[$key] );
399  }
400  if ( $comp < 0 ) {
401  $letterMap[$key] = $letter;
402  }
403  } else {
404  $letterMap[$key] = $letter;
405  }
406  }
407  ksort( $letterMap, SORT_STRING );
408 
409  /* Remove duplicate prefixes. Basically if something has a sortkey
410  * which is a prefix of some other sortkey, then it is an
411  * expansion and probably should not be considered a section
412  * header.
413  *
414  * For example 'þ' is sometimes sorted as if it is the letters
415  * 'th'. Other times it is its own primary element. Another
416  * example is '₨'. Sometimes its a currency symbol. Sometimes it
417  * is an 'R' followed by an 's'.
418  *
419  * Additionally an expanded element should always sort directly
420  * after its first element due to they way sortkeys work.
421  *
422  * UCA sortkey elements are of variable length but no collation
423  * element should be a prefix of some other element, so I think
424  * this is safe. See:
425  * - https://ssl.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm
426  * - http://site.icu-project.org/design/collation/uca-weight-allocation
427  *
428  * Additionally, there is something called primary compression to
429  * worry about. Basically, if you have two primary elements that
430  * are more than one byte and both start with the same byte then
431  * the first byte is dropped on the second primary. Additionally
432  * either \x03 or \xFF may be added to mean that the next primary
433  * does not start with the first byte of the first primary.
434  *
435  * This shouldn't matter much, as the first primary is not
436  * changed, and that is what we are comparing against.
437  *
438  * tl;dr: This makes some assumptions about how icu implements
439  * collations. It seems incredibly unlikely these assumptions
440  * will change, but nonetheless they are assumptions.
441  */
442 
443  $prev = false;
444  $duplicatePrefixes = [];
445  foreach ( $letterMap as $key => $value ) {
446  // Remove terminator byte. Otherwise the prefix
447  // comparison will get hung up on that.
448  $trimmedKey = rtrim( $key, "\0" );
449  if ( $prev === false || $prev === '' ) {
450  $prev = $trimmedKey;
451  // We don't yet have a collation element
452  // to compare against, so continue.
453  continue;
454  }
455 
456  // Due to the fact the array is sorted, we only have
457  // to compare with the element directly previous
458  // to the current element (skipping expansions).
459  // An element "X" will always sort directly
460  // before "XZ" (Unless we have "XY", but we
461  // do not update $prev in that case).
462  if ( substr( $trimmedKey, 0, strlen( $prev ) ) === $prev ) {
463  $duplicatePrefixes[] = $key;
464  // If this is an expansion, we don't want to
465  // compare the next element to this element,
466  // but to what is currently $prev
467  continue;
468  }
469  $prev = $trimmedKey;
470  }
471  foreach ( $duplicatePrefixes as $badKey ) {
472  wfDebug( "Removing '{$letterMap[$badKey]}' from first letters." );
473  unset( $letterMap[$badKey] );
474  // This code assumes that unsetting does not change sort order.
475  }
476  $data = [
477  'chars' => array_values( $letterMap ),
478  'keys' => array_keys( $letterMap ),
479  ];
480 
481  // Reduce memory usage before caching
482  unset( $letterMap );
483 
484  return $data;
485  }
486 
495  private function getPrecompiledData( $name ) {
496  global $IP;
497  $file = "$IP/serialized/$name";
498  if ( file_exists( $file ) ) {
499  $blob = file_get_contents( $file );
500  if ( $blob ) {
501  return unserialize( $blob );
502  }
503  }
504  return false;
505  }
506 
512  public function getLetterByIndex( $index ) {
513  return $this->getFirstLetterData()['chars'][$index];
514  }
515 
521  public function getSortKeyByLetterIndex( $index ) {
522  return $this->getFirstLetterData()['keys'][$index];
523  }
524 
529  public function getFirstLetterCount() {
530  return count( $this->getFirstLetterData()['chars'] );
531  }
532 
539  public static function isCjk( $codepoint ) {
540  foreach ( self::CJK_BLOCKS as $block ) {
541  if ( $codepoint >= $block[0] && $codepoint <= $block[1] ) {
542  return true;
543  }
544  }
545  return false;
546  }
547 
555  public static function getUnicodeVersionForICU() {
556  $icuVersion = INTL_ICU_VERSION;
557  if ( !$icuVersion ) {
558  return false;
559  }
560 
561  $versionPrefix = substr( $icuVersion, 0, 3 );
562  // Source: http://site.icu-project.org/download
563  $map = [
564  '67.' => '13.0',
565  '66.' => '13.0',
566  '65.' => '12.0',
567  '64.' => '12.0',
568  '63.' => '11.0',
569  '62.' => '11.0',
570  '61.' => '10.0',
571  '60.' => '10.0',
572  '59.' => '9.0',
573  '58.' => '9.0',
574  '57.' => '8.0',
575  '56.' => '8.0',
576  '55.' => '7.0',
577  '54.' => '7.0',
578  '53.' => '6.3',
579  '52.' => '6.3',
580  '51.' => '6.2',
581  '50.' => '6.2',
582  '49.' => '6.1',
583  '4.8' => '6.0',
584  '4.6' => '6.0',
585  '4.4' => '5.2',
586  '4.2' => '5.1',
587  '4.0' => '5.1',
588  '3.8' => '5.0',
589  '3.6' => '5.0',
590  '3.4' => '4.1',
591  ];
592 
593  return $map[$versionPrefix] ?? false;
594  }
595 }
CACHE_ANYTHING
const CACHE_ANYTHING
Definition: Defines.php:85
IcuCollation\getFirstLetterCount
getFirstLetterCount()
Definition: IcuCollation.php:529
MediaWiki\Languages\LanguageFactory
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: LanguageFactory.php:42
IcuCollation\$primaryCollator
Collator $primaryCollator
Definition: IcuCollation.php:30
IcuCollation\getPrimarySortKey
getPrimarySortKey( $string)
Definition: IcuCollation.php:279
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1186
Collation
Definition: Collation.php:30
IcuCollation\CJK_BLOCKS
const CJK_BLOCKS
Unified CJK blocks.
Definition: IcuCollation.php:56
IcuCollation\getPrecompiledData
getPrecompiledData( $name)
Get an object from the precompiled serialized directory.
Definition: IcuCollation.php:495
IcuCollation\__construct
__construct(LanguageFactory $languageFactory, $locale)
Definition: IcuCollation.php:248
IcuCollation\$mainCollator
Collator $mainCollator
Definition: IcuCollation.php:33
MWException
MediaWiki exception.
Definition: MWException.php:29
IcuCollation\$digitTransformLanguage
Language $digitTransformLanguage
Definition: IcuCollation.php:39
$blob
$blob
Definition: testCompression.php:70
IcuCollation\getSortKeyByLetterIndex
getSortKeyByLetterIndex( $index)
Definition: IcuCollation.php:521
IcuCollation\isCjk
static isCjk( $codepoint)
Test if a code point is a CJK (Chinese, Japanese, Korean) character.
Definition: IcuCollation.php:539
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:894
MediaWiki\Languages\LanguageFactory\getLanguage
getLanguage( $code)
Get a cached or new language object for a given language code.
Definition: LanguageFactory.php:111
IcuCollation\getLetterByIndex
getLetterByIndex( $index)
Definition: IcuCollation.php:512
IcuCollation\getFirstLetter
getFirstLetter( $string)
Given a string, return the logical "first letter" to be used for grouping on category pages and so on...
Definition: IcuCollation.php:283
IcuCollation\getFirstLetterData
getFirstLetterData()
Definition: IcuCollation.php:328
IcuCollation\FIRST_LETTER_VERSION
const FIRST_LETTER_VERSION
Definition: IcuCollation.php:27
IcuCollation\$locale
string $locale
Definition: IcuCollation.php:36
unserialize
unserialize( $serialized)
Definition: ApiMessageTrait.php:146
IcuCollation\getUnicodeVersionForICU
static getUnicodeVersionForICU()
Return the version of Unicode appropriate for the version of ICU library currently in use,...
Definition: IcuCollation.php:555
$cache
$cache
Definition: mcc.php:33
IcuCollation\TAILORING_FIRST_LETTERS
const TAILORING_FIRST_LETTERS
Additional characters (or character groups) to be considered separate letters for given languages,...
Definition: IcuCollation.php:95
IcuCollation\$useNumericCollation
bool $useNumericCollation
Definition: IcuCollation.php:42
ArrayUtils\findLowerBound
static findLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target)
Do a binary search, and return the index of the largest item that sorts less than or equal to the tar...
Definition: ArrayUtils.php:112
IcuCollation\getSortKey
getSortKey( $string)
Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
Definition: IcuCollation.php:275
IcuCollation\$firstLetterData
array $firstLetterData
Definition: IcuCollation.php:45
$IP
$IP
Definition: WebStart.php:49
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42
IcuCollation\fetchFirstLetterData
fetchFirstLetterData()
Definition: IcuCollation.php:350
ObjectCache\getLocalServerInstance
static getLocalServerInstance( $fallback=CACHE_NONE)
Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
Definition: ObjectCache.php:255
IcuCollation
Definition: IcuCollation.php:26