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