Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / collation / CollationFa.php
blob9cce087d3a58d8167f42a15bcf7bdc8e0f33e183
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 /**
22 * Temporary workaround for incorrect collation of Persian language ('fa') in ICU 52 (bug T139110).
24 * All of the following will be considered separate letters for category headings in Persian:
25 * - Characters 'و' 'ا' (often appear at the beginning of words)
26 * - Characters 'ٲ' 'ٳ' (may appear at the beginning of words in loanwords)
27 * - Characters 'ء' 'ئ' (don't appear at the beginning of words, but it's easier to implement)
29 * @since 1.29
31 class CollationFa extends IcuCollation {
32 private $tertiaryCollator;
34 public function __construct() {
35 parent::__construct( 'fa' );
36 $this->tertiaryCollator = Collator::create( 'fa' );
39 public function getPrimarySortKey( $string ) {
40 $primary = parent::getPrimarySortKey( $string );
41 // We have to use a tertiary sortkey for everything with the primary sortkey of 2627.
42 // Otherwise, the "Remove duplicate prefixes" logic in IcuCollation would remove them.
43 // This matches sortkeys for the following characters: ء ئ ا و ٲ ٳ
44 if ( substr( $primary, 0, 2 ) === "\x26\x27" ) {
45 wfDebug( "Using tertiary sortkey for '$string'\n" );
46 return $this->tertiaryCollator->getSortKey( $string );
48 return $primary;