ebc6658785a3aa261e5ffa58ab7d32db44f3f4e9
[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 # This file and LanguageUtf8.php may be included from within functions, so
31 # we need to have global statements
32 global $wgInputEncoding, $wgOutputEncoding;
33
34 $wgInputEncoding = "ISO-8859-1";
35 $wgOutputEncoding = "ISO-8859-1";
36
37 function utf8_decode_array( $arr ) {
38 if( !is_array( $arr ) ) {
39 wfDebugDieBacktrace( "utf8_decode_array given non-array" );
40 }
41 return array_map( "utf8_decode", $arr );
42 }
43
44 #
45 # This is a proxy object; the Language instance handed to us speaks
46 # UTF-8, while the wiki outside speaks Latin-1. We translate as
47 # necessary so neither knows the other is in the wrong charset.
48 #
49 class LanguageLatin1 {
50 var $lang;
51
52 function LanguageLatin1( &$language ) {
53 $this->lang =& $language;
54 }
55
56 function getDefaultUserOptions() {
57 return $this->lang->getDefaultUserOptions();
58 }
59
60 function getBookstoreList() {
61 return utf8_decode_array( $this->lang->getBookstoreList() );
62 }
63
64 function getNamespaces() {
65 return utf8_decode_array( $this->lang->getNamespaces() );
66 }
67
68 function getNsText( $index ) {
69 return utf8_decode( $this->lang->getNsText( $index ) );
70 }
71
72 function getNsIndex( $text ) {
73 return $this->lang->getNsIndex( utf8_encode( $text ) );
74 }
75
76 function specialPage( $name ) {
77 # At least one function calls this with Special:Undelete/Article_title, so it needs encoding
78 return utf8_decode( $this->lang->specialPage( utf8_encode( $name ) ) );
79 }
80
81 function getQuickbarSettings() {
82 return utf8_decode_array( $this->lang->getQuickbarSettings() );
83 }
84
85 function getSkinNames() {
86 return utf8_decode_array( $this->lang->getSkinNames() );
87 }
88
89 function getMathNames() {
90 return utf8_decode_array( $this->lang->getMathNames() );
91 }
92
93 function getDateFormats() {
94 return utf8_decode_array( $this->lang->getDateFormats() );
95 }
96
97 function getUserToggles() {
98 return utf8_decode_array( $this->lang->getUserToggles() );
99 }
100
101 function getUserToggle( $tog ) {
102 return utf8_decode( $this->lang->getUserToggle( $tog ) );
103 }
104
105 function getLanguageNames() {
106 return utf8_decode_array( $this->lang->getLanguageNames() );
107 }
108
109 function getLanguageName( $code ) {
110 return utf8_decode( $this->lang->getLanguageName( $code ) );
111 }
112
113 function getMonthName( $key ) {
114 return utf8_decode( $this->lang->getMonthName( $key ) );
115 }
116
117 function getMonthNameGen( $key ) {
118 return utf8_decode( $this->lang->getMonthNameGen( $key ) );
119 }
120
121 function getMonthAbbreviation( $key ) {
122 return utf8_decode( $this->lang->getMonthAbbreviation( $key ) );
123 }
124
125 function getWeekdayName( $key ) {
126 return utf8_decode( $this->lang->getWeekdayName( $key ) );
127 }
128
129 function userAdjust( $ts ) {
130 return $this->lang->userAdjust( $ts );
131 }
132
133 function date( $ts, $adj = false ) {
134 return utf8_decode( $this->lang->date( $ts, $adj ) );
135 }
136
137 function time( $ts, $adj = false, $seconds = false ) {
138 return utf8_decode( $this->lang->time( $ts, $adj ) );
139 }
140
141 function timeanddate( $ts, $adj = false ) {
142 return utf8_decode( $this->lang->timeanddate( $ts, $adj ) );
143 }
144
145 function rfc1123( $ts ) {
146 # ASCII by definition
147 return $this->lang->rfc1123( $ts );
148 }
149
150 function getValidSpecialPages() {
151 return utf8_decode_array( $this->lang->getValidSpecialPages() );
152 }
153
154 function getSysopSpecialPages() {
155 return utf8_decode_array( $this->lang->getSysopSpecialPages() );
156 }
157
158 function getDeveloperSpecialPages() {
159 return utf8_decode_array( $this->lang->getDeveloperSpecialPages() );
160 }
161
162 function getMessage( $key ) {
163 return utf8_decode( $this->lang->getMessage( $key ) );
164 }
165
166 function getAllMessages() {
167 return utf8_decode_array( $this->lang->getAllMessages() );
168 }
169
170 function iconv( $in, $out, $string ) {
171 # Use 8-bit version
172 return Language::iconv( $in, $out, $string );
173 }
174
175 function ucfirst( $string ) {
176 # Use 8-bit version
177 return Language::ucfirst( $string );
178 }
179
180 function lcfirst( $s ) {
181 # Use 8-bit version
182 return Language::lcfirst( $s );
183 }
184
185 function checkTitleEncoding( $s ) {
186 # Use 8-bit version
187 return Language::checkTitleEncoding( $s );
188 }
189
190 function stripForSearch( $in ) {
191 # Use 8-bit version
192 return Language::stripForSearch( $in );
193 }
194
195 function firstChar( $s ) {
196 # Use 8-bit version
197 return Language::firstChar( $s );
198 }
199
200 function setAltEncoding() {
201 # Not sure if this should be handled
202 $this->lang->setAltEncoding();
203 }
204
205 function recodeForEdit( $s ) {
206 # Use 8-bit version
207 return Language::recodeForEdit( $s );
208 }
209
210 function recodeInput( $s ) {
211 # Use 8-bit version
212 return Language::recodeInput( $s );
213 }
214
215 function isRTL() {
216 # boolean
217 return $this->lang->isRTL();
218 }
219
220 function linkPrefixExtension() {
221 # boolean
222 return $this->lang->linkPrefixExtension();
223 }
224
225 function &getMagicWords() {
226 return utf8_decode_array( $this->lang->getMagicWords() );
227 }
228
229 function getMagic( &$mw ) {
230 # Not sure how to handle this.
231 # A moot point perhaps as few language files currently
232 # assign localised magic words, and none of the ones we
233 # need backwards compatibility for.
234 return $this->lang->getMagic( $mw );
235 }
236
237 function emphasize( $text ) {
238 # It's unlikely that the emphasis markup itself will
239 # include any non-ASCII chars.
240 return $this->lang->emphasize( $text );
241 }
242
243 function formatNum( $number ) {
244 # Probably not necessary...
245 return utf8_decode( $this->lang->formatNum( $number ) );
246 }
247
248 function listToText( $l ) {
249 # It's unlikely that the list markup itself will
250 # include any non-ASCII chars. (?)
251 return $this->lang->listToText( $l );
252 }
253
254 function truncate( $string, $length, $ellipsis = "" ) {
255 return Language::truncate( $string, $length, $ellipsis );
256 }
257
258 function convertGrammar( $word, $case ) {
259 return $word;
260 }
261
262 function getPreferredVariant() {
263 return $this->lang->getPreferredVariant();
264 }
265
266 function segmentForDiff( $text ) {
267 return $text;
268 }
269
270 function unsegmentForDiff( $text ) {
271 return $text;
272 }
273
274 function convert( $text, $isTitle=false ) {
275 return utf8_decode( $this->lang->convert( utf8_encode( $text ), $isTitle ) );
276 }
277
278 function autoConvert($text, $toVariant=false) {
279 return utf8_decode( $this->lang->autoConvert( utf8_encode( $text ), $toVariant ) );
280 }
281
282 /* hook for converting the title, which may needs special treatment
283 */
284 function convertTitle($text) {
285 return utf8_decode( $this->lang->convertTitle( utf8_encode( $text ) ) );
286 }
287
288 function getVariants() {
289 return $this->lang->getVariants();
290 }
291
292 function convertForSearchResult( $termsArray ) {
293 return $termsArray;
294 }
295
296 function getExtraHashOptions() {
297 return array();
298 }
299
300 }
301
302 ?>