Add digit transformation function Language::formatNum() for Arabic and other
[lhc/web/wiklou.git] / languages / LanguageAr.php
1 <?php
2 # See language.doc
3 include_once("LanguageUtf8.php");
4
5 /* private */ $wgNamespaceNamesAr = array(
6 -2 => "ملف",
7 -1 => "خاص",
8 0 => "",
9 1 => "نقاش",
10 2 => "مستخدم",
11 3 => "نقاش_المستخدم",
12 4 => "ويكيبيديا",
13 5 => "ويكيبيديا_نقاش",
14 6 => "صورة",
15 7 => "نقاش_الصورة",
16 8 => "MediaWiki",
17 9 => "MediaWiki_talk",
18 );
19
20 /* private */ $wgWeekdayNamesAr = array(
21 "الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس",
22 "الجمعة", "السبت"
23 );
24
25 /* private */ $wgMonthNamesAr = array(
26 "يناير", "فبراير", "مارس", "ابريل", "مايو", "يونيو",
27 "يوليو", "أغسطس", "سبتمبر", "اكتوبر", "نوفمبر",
28 "ديسمبر"
29 );
30
31 class LanguageAr extends LanguageUtf8 {
32 var $digitTransTable = array(
33 "0" => "٠",
34 "1" => "١",
35 "2" => "٢",
36 "3" => "٣",
37 "4" => "٤",
38 "5" => "٥",
39 "6" => "٦",
40 "7" => "٧",
41 "8" => "٨",
42 "9" => "٩",
43 "%" => "٪",
44 "." => "٫",
45 "," => "٬"
46 );
47
48 # TODO: TRANSLATION!
49
50 # Inherit everything except...
51
52 function getNamespaces()
53 {
54 global $wgNamespaceNamesAr;
55 return $wgNamespaceNamesAr;
56 }
57
58
59 function getNsText( $index )
60 {
61 global $wgNamespaceNamesAr;
62 return $wgNamespaceNamesAr[$index];
63 }
64
65 function getNsIndex( $text )
66 {
67 global $wgNamespaceNamesAr;
68
69 foreach ( $wgNamespaceNamesAr as $i => $n )
70 {
71 if ( 0 == strcasecmp( $n, $text ) ) { return $i; }
72 }
73 return LanguageUtf8::getNsIndex( $text );
74 }
75
76 function getMonthName( $key )
77 {
78 global $wgMonthNamesAr;
79 return $wgMonthNamesAr[$key-1];
80 }
81
82 function getMonthAbbreviation( $key )
83 {
84 /* No abbreviations in Arabic */
85 return $this->getMonthName( $key );
86 }
87
88 function getWeekdayName( $key )
89 {
90 global $wgWeekdayNamesAr;
91 return $wgWeekdayNamesAr[$key-1];
92 }
93
94 function isRTL() { return true; }
95
96 function linkPrefixExtension() { return true; }
97
98 function getDefaultUserOptions () {
99 global $wgDefaultUserOptionsEn;
100 $opt = $wgDefaultUserOptionsEn;
101
102 # Swap sidebar to right side by default
103 $opt['quickbar'] = 2;
104 return $opt ;
105 }
106
107 function checkTitleEncoding( $s ) {
108 global $wgInputEncoding;
109
110 # Check for non-UTF-8 URLs; assume they are windows-1256?
111 $ishigh = preg_match( '/[\x80-\xff]/', $s);
112 $isutf = ($ishigh ? preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
113 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true );
114
115 if( $ishigh and !$isutf )
116 return iconv( "windows-1256", "utf-8", $s );
117
118 return $s;
119 }
120
121 function formatNum( $number ) {
122 return strtr( $number, $this->digitTransTable );
123 }
124 }
125
126 ?>