summaryrefslogtreecommitdiff
path: root/languages/classes/LanguageAr.php
blob: 77c46025129a1658e22ae090c9347c5168c70490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/** Arabic (العربية)
 *
 * @ingroup Language
 *
 * @author Niklas Laxström
 */
class LanguageAr extends Language {
	function convertPlural( $count, $forms ) {
		if ( !count( $forms ) ) { return ''; }
		$forms = $this->preConvertPlural( $forms, 6 );

		if ( $count == 0 ) {
			$index = 0;
		} elseif ( $count == 1 ) {
			$index = 1;
		} elseif ( $count == 2 ) {
			$index = 2;
		} elseif ( $count % 100 >= 3 && $count % 100 <= 10 ) {
			$index = 3;
		} elseif ( $count % 100 >= 11 && $count % 100 <= 99 ) {
			$index = 4;
		} else {
			$index = 5;
		}
		return $forms[$index];
	}

	/**
	 * Temporary hack for bug 9413: replace Arabic presentation forms with their
	 * standard equivalents.
	 *
	 * FIXME: This is language-specific for now only to avoid the negative
	 * performance impact of enabling it for all languages.
	 */
	function normalize( $s ) {
		global $wgFixArabicUnicode;
		$s = parent::normalize( $s );
		if ( $wgFixArabicUnicode ) {
			$s = $this->transformUsingPairFile( 'normalize-ar.ser', $s );
		}
		return $s;
	}
}