sitenotice
[lhc/web/wiklou.git] / languages / LanguageLatin1.php
1 <?php
2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
19
20 #
21 # Latin-1 compatibility layer hack.
22 #
23 # Enable by setting "$wgUseLatin1 = true;" in LocalSettings.php
24 # (Preferably at install time so you get the messages right!)
25 #
26 # This will replace anything that can't be described in Latin-1 with
27 # an ugly question mark (?) so don't use this mode on languages that
28 # aren't suited to it!
29 #
30
31 $wgInputEncoding = "ISO-8859-1";
32 $wgOutputEncoding = "ISO-8859-1";
33
34 function utf8_decode_array( $arr ) {
35 if( !is_array( $arr ) ) {
36 wfDebugDieBacktrace( "utf8_decode_array given non-array" );
37 }
38 return array_map( "utf8_decode", $arr );
39 }
40
41 #
42 # This is a proxy object; the Language instance handed to us speaks
43 # UTF-8, while the wiki outside speaks Latin-1. We translate as
44 # necessary so neither knows the other is in the wrong charset.
45 #
46 class LanguageLatin1 {
47 var $lang;
48
49 function LanguageLatin1( &$language ) {
50 $this->lang =& $language;
51 }
52
53 function getDefaultUserOptions() {
54 return $this->lang->getDefaultUserOptions();
55 }
56
57 function getBookstoreList() {
58 return utf8_decode_array( $this->lang->getBookstoreList() );
59 }
60
61 function getNamespaces() {
62 return utf8_decode_array( $this->lang->getNamespaces() );
63 }
64
65 function getNsText( $index ) {
66 return utf8_decode( $this->lang->getNsText( $index ) );
67 }
68
69 function getNsIndex( $text ) {
70 return $this->lang->getNsIndex( utf8_encode( $text ) );
71 }
72
73 function specialPage( $name ) {
74 # At least one function calls this with Special:Undelete/Article_title, so it needs encoding
75 return utf8_decode( $this->lang->specialPage( utf8_encode( $name ) ) );
76 }
77
78 function getQuickbarSettings() {
79 return utf8_decode_array( $this->lang->getQuickbarSettings() );
80 }
81
82 function getSkinNames() {
83 return utf8_decode_array( $this->lang->getSkinNames() );
84 }
85
86 function getMathNames() {
87 return utf8_decode_array( $this->lang->getMathNames() );
88 }
89
90 function getDateFormats() {
91 return utf8_decode_array( $this->lang->getDateFormats() );
92 }
93
94 function getUserToggles() {
95 return utf8_decode_array( $this->lang->getUserToggles() );
96 }
97
98 function getUserToggle( $tog ) {
99 return utf8_decode( $this->lang->getUserToggle( $tog ) );
100 }
101
102 function getLanguageNames() {
103 return utf8_decode_array( $this->lang->getLanguageNames() );
104 }
105
106 function getLanguageName( $code ) {
107 return utf8_decode( $this->lang->getLanguageName( $code ) );
108 }
109
110 function getMonthName( $key ) {
111 return utf8_decode( $this->lang->getMonthName( $key ) );
112 }
113
114 function getMonthNameGen( $key ) {
115 return utf8_decode( $this->lang->getMonthNameGen( $key ) );
116 }
117
118 function getMonthAbbreviation( $key ) {
119 return utf8_decode( $this->lang->getMonthAbbreviation( $key ) );
120 }
121
122 function getWeekdayName( $key ) {
123 return utf8_decode( $this->lang->getWeekdayName( $key ) );
124 }
125
126 function userAdjust( $ts ) {
127 return $this->lang->userAdjust( $ts );
128 }
129
130 function date( $ts, $adj = false ) {
131 return utf8_decode( $this->lang->date( $ts, $adj ) );
132 }
133
134 function time( $ts, $adj = false, $seconds = false ) {
135 return utf8_decode( $this->lang->time( $ts, $adj ) );
136 }
137
138 function timeanddate( $ts, $adj = false ) {
139 return utf8_decode( $this->lang->timeanddate( $ts, $adj ) );
140 }
141
142 function rfc1123( $ts ) {
143 # ASCII by definition
144 return $this->lang->rfc1123( $ts );
145 }
146
147 function getValidSpecialPages() {
148 return utf8_decode_array( $this->lang->getValidSpecialPages() );
149 }
150
151 function getSysopSpecialPages() {
152 return utf8_decode_array( $this->lang->getSysopSpecialPages() );
153 }
154
155 function getDeveloperSpecialPages() {
156 return utf8_decode_array( $this->lang->getDeveloperSpecialPages() );
157 }
158
159 function getMessage( $key ) {
160 return utf8_decode( $this->lang->getMessage( $key ) );
161 }
162
163 function getAllMessages() {
164 return utf8_decode_array( $this->lang->getAllMessages() );
165 }
166
167 function iconv( $in, $out, $string ) {
168 # Use 8-bit version
169 return Language::iconv( $in, $out, $string );
170 }
171
172 function ucfirst( $string ) {
173 # Use 8-bit version
174 return Language::ucfirst( $string );
175 }
176
177 function lcfirst( $s ) {
178 # Use 8-bit version
179 return Language::lcfirst( $s );
180 }
181
182 function checkTitleEncoding( $s ) {
183 # Use 8-bit version
184 return Language::checkTitleEncoding( $s );
185 }
186
187 function stripForSearch( $in ) {
188 # Use 8-bit version
189 return Language::stripForSearch( $in );
190 }
191
192 function firstChar( $s ) {
193 # Use 8-bit version
194 return Language::firstChar( $s );
195 }
196
197 function setAltEncoding() {
198 # Not sure if this should be handled
199 $this->lang->setAltEncoding();
200 }
201
202 function recodeForEdit( $s ) {
203 # Use 8-bit version
204 return Language::recodeForEdit( $s );
205 }
206
207 function recodeInput( $s ) {
208 # Use 8-bit version
209 return Language::recodeInput( $s );
210 }
211
212 function isRTL() {
213 # boolean
214 return $this->lang->isRTL();
215 }
216
217 function linkPrefixExtension() {
218 # boolean
219 return $this->lang->linkPrefixExtension();
220 }
221
222 function &getMagicWords() {
223 return utf8_decode_array( $this->lang->getMagicWords() );
224 }
225
226 function getMagic( &$mw ) {
227 # Not sure how to handle this.
228 # A moot point perhaps as few language files currently
229 # assign localised magic words, and none of the ones we
230 # need backwards compatibility for.
231 return $this->lang->getMagic( $mw );
232 }
233
234 function emphasize( $text ) {
235 # It's unlikely that the emphasis markup itself will
236 # include any non-ASCII chars.
237 return $this->lang->emphasize( $text );
238 }
239
240 function formatNum( $number ) {
241 # Probably not necessary...
242 return utf8_decode( $this->lang->formatNum( $number ) );
243 }
244
245 function listToText( $l ) {
246 # It's unlikely that the list markup itself will
247 # include any non-ASCII chars. (?)
248 return $this->lang->listToText( $l );
249 }
250 }
251
252 ?>