Manual:$wgCategoryCollation

From MediaWiki.org
Jump to: navigation, search

Other languages:
English • ‎français • ‎日本語 • ‎polski • ‎中文
Category: $wgCategoryCollation
What collation categories use to sort with
Introduced in version: 1.17.0 (r72308)
Removed in version: still in use
Allowed values: string
Default value: uppercase
Other settings: Alphabetical | By function

Details[edit]

The setting determines what collation algorithm should be used to sort category listings. See also MediaWiki 1.17/Category sortingMediaWiki 1.17/Category sorting.

Currently supports:

  • uppercase [default]: make everything uppercase, then sort by binary value of string when stored as UTF-8. Essentially case-insensitive sort by code point.
  • numeric [MW 1.28+]: Same as uppercase, but with numeric sorting.
  • identity [MW 1.18+]: sort by binary value of string when stored as UTF-8 (without converting to uppercase). Essentially sort by code point.
  • uca-default [MW 1.17+]: Unicode collation algorithm – complex, much more multilingual-friendly category collation.
  • uca-default-u-kn [MW 1.28+]: uca-default with numeric sorting.
  • uca-<langcode> [MW 1.21+]: uca-default with language-specific adjustments. See below.
  • uca-<langcode>-u-kn [MW 1.28+]: uca-<langcode> with numeric sorting.

Since MediaWiki 1.18, extensions can add extra collations via the Collation::factorymanual:Hooks/Collation::factory hook.

The value is also stored inside the categorylinks table to determine which rows need updating when the collation algorithm changes.

Warning Warning:
  • After changing this option, you must run updateCollation.phpManual:updateCollation.php to recompute sort keys for all pages, or your categories will be sorted inconsistently.
  • Updating collations is slow and may take several hours on large wikis.
  • uca-default/uca-xx collations require the PHP intl extension.
  • If you're seeing unexpected results after changing this to uca-default/uca-xx (such as pages starting with "A" sorted under the "⅍" symbol, etc.), you probably have to generate collation data appropriate for your version of ICU using the generateCollationData.phpManual:generateCollationData.php maintenance script (task T45740), then rerun updateCollation.php with a --force parameter.
  • You have to purgepurge category pages after running updateCollation.php to see the results.

Language-specific collations[edit]

MediaWiki also supports 70 collations designed for specific languages. These are based on uca-default and have the same requirements; they are named uca-<langcode>, where <langcode> is one of:

af, ast, az, be, be-tarask, bg, br, bs, ca, co, cs, cy, da, de, dsb, el, en, eo, es, et, eu, fa, fi, fo, fr, fur, fy, ga, gd, gl, hr, hsb, hu, is, it, kk, kl, ku, ky, la, lb, lt, lv, mk, mo, mt, nl, no, oc, pl, pt, rm, ro, ru, rup, sco, sk, sl, smn, sq, sr, sv, ta, tk, tl, tr, tt, uk, uz, vi

For example, to use a collation for Spanish, one would use the uca-es collation.

Using these collations provides both correct sorting order for given language and proper headings for first letters of article titles.

Getting new collations added[edit]

There are two parts to having a new language supported:

  • It being supported by the ICU library (the list of language codes it supports is available at [1]). Note, however, that Wikimedia's production servers do not use the latest version of the ICU library. As of 2016, they use version 52.1, which supports a significantly smaller set of languages.
  • It being additionally supported by MediaWiki itself (this basically requires listing the additional characters, or character groups, that are considered separate letters in the given language, in addition to the basic alphabet) – the always up-to-date list of currently supported ones is available at includes/collation/IcuCollation.php).

It might also be the case that the default ICU ordering ('uca-default' collation) orders the titles correctly, but does not correctly separate the letters – it can be used for the first step in that case. Sometimes the letter ordering of a different language might fit yours, if they are related – a custom collation can sometimes be provided in such case (there is one for Sorani Kurdish / Central Kurdish language ('ckb') already, called xx-uca-ckb includes/Collation.php).

Numeric sorting[edit]

Comparison between regular sorting (top) and numeric sorting (bottom)

Under numeric sorting, pages will be sorted as such: 1, 2, 9, 10, 11, 20, 21, 99, 100. Under regular (non-numeric) sorting, pages will be sorted as such: 1, 10, 100, 11, 2, 20, 21, 9, 99. If numeric sorting is used, all pages starting with a number will be sorted together under a single header: "0–9". If regular sorting is used, pages starting with a number will be sorted under separate headers for whichever number each title begins with: "0", "1", "2", etc. For more information about numeric sorting, see the Unicode Technical Standard #10. To test numeric sorting, see the ICU Collation Demo. Note that numeric sorting only works for unbroken sequences of digits. Digits separated by commas, periods, or spaces are treated as separate numbers.

External links[edit]