Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

LanguageLatin1.php

Go to the documentation of this file.
00001 <?php 00002 # Copyright (C) 2004 Brion Vibber <brion@pobox.com> 00003 # http://www.mediawiki.org/ 00004 # 00005 # This program is free software; you can redistribute it and/or modify 00006 # it under the terms of the GNU General Public License as published by 00007 # the Free Software Foundation; either version 2 of the License, or 00008 # (at your option) any later version. 00009 # 00010 # This program is distributed in the hope that it will be useful, 00011 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 # GNU General Public License for more details. 00014 # 00015 # You should have received a copy of the GNU General Public License along 00016 # with this program; if not, write to the Free Software Foundation, Inc., 00017 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 # http://www.gnu.org/copyleft/gpl.html 00019 00020 # 00021 # Latin-1 compatibility layer hack. 00022 # 00023 # Enable by setting "$wgUseLatin1 = true;" in LocalSettings.php 00024 # (Preferably at install time so you get the messages right!) 00025 # 00026 # This will replace anything that can't be described in Latin-1 with 00027 # an ugly question mark (?) so don't use this mode on languages that 00028 # aren't suited to it! 00029 # 00030 00031 $wgInputEncoding = "iso-8859-1"; 00032 $wgOutputEncoding = "iso-8859-1"; 00033 00034 function utf8_decode_array( $arr ) { 00035 if( !is_array( $arr ) ) { 00036 wfDebugDieBacktrace( "utf8_decode_array given non-array" ); 00037 } 00038 return array_map( "utf8_decode", $arr ); 00039 } 00040 00041 # 00042 # This is a proxy object; the Language instance handed to us speaks 00043 # UTF-8, while the wiki outside speaks Latin-1. We translate as 00044 # necessary so neither knows the other is in the wrong charset. 00045 # 00046 class LanguageLatin1 { 00047 var $lang; 00048 00049 function LanguageLatin1( &$language ) { 00050 $this->lang =& $language; 00051 } 00052 00053 function getDefaultUserOptions() { 00054 return $this->lang->getDefaultUserOptions(); 00055 } 00056 00057 function getBookstoreList() { 00058 return utf8_decode_array( $this->lang->getBookstoreList() ); 00059 } 00060 00061 function getNamespaces() { 00062 return utf8_decode_array( $this->lang->getNamespaces() ); 00063 } 00064 00065 function getNsText( $index ) { 00066 return utf8_decode( $this->lang->getNsText( $index ) ); 00067 } 00068 00069 function getNsIndex( $text ) { 00070 return $this->lang->getNsIndex( utf8_encode( $text ) ); 00071 } 00072 00073 function specialPage( $name ) { 00074 # At least one function calls this with Special:Undelete/Article_title, so it needs encoding 00075 return utf8_decode( $this->lang->specialPage( utf8_encode( $name ) ) ); 00076 } 00077 00078 function getQuickbarSettings() { 00079 return utf8_decode_array( $this->lang->getQuickbarSettings() ); 00080 } 00081 00082 function getSkinNames() { 00083 return utf8_decode_array( $this->lang->getSkinNames() ); 00084 } 00085 00086 function getMathNames() { 00087 return utf8_decode_array( $this->lang->getMathNames() ); 00088 } 00089 00090 function getDateFormats() { 00091 return utf8_decode_array( $this->lang->getDateFormats() ); 00092 } 00093 00094 function getUserToggles() { 00095 return utf8_decode_array( $this->lang->getUserToggles() ); 00096 } 00097 00098 function getUserToggle( $tog ) { 00099 return utf8_decode( $this->lang->getUserToggle( $tog ) ); 00100 } 00101 00102 function getLanguageNames() { 00103 return utf8_decode_array( $this->lang->getLanguageNames() ); 00104 } 00105 00106 function getLanguageName( $code ) { 00107 return utf8_decode( $this->lang->getLanguageName( $code ) ); 00108 } 00109 00110 function getMonthName( $key ) { 00111 return utf8_decode( $this->lang->getMonthName( $key ) ); 00112 } 00113 00114 function getMonthNameGen( $key ) { 00115 return utf8_decode( $this->lang->getMonthNameGen( $key ) ); 00116 } 00117 00118 function getMonthAbbreviation( $key ) { 00119 return utf8_decode( $this->lang->getMonthAbbreviation( $key ) ); 00120 } 00121 00122 function getWeekdayName( $key ) { 00123 return utf8_decode( $this->lang->getWeekdayName( $key ) ); 00124 } 00125 00126 function userAdjust( $ts ) { 00127 return $this->lang->userAdjust( $ts ); 00128 } 00129 00130 function date( $ts, $adj = false ) { 00131 return utf8_decode( $this->lang->date( $ts, $adj ) ); 00132 } 00133 00134 function time( $ts, $adj = false, $seconds = false ) { 00135 return utf8_decode( $this->lang->time( $ts, $adj ) ); 00136 } 00137 00138 function timeanddate( $ts, $adj = false ) { 00139 return utf8_decode( $this->lang->timeanddate( $ts, $adj ) ); 00140 } 00141 00142 function rfc1123( $ts ) { 00143 # ASCII by definition 00144 return $this->lang->rfc1123( $ts ); 00145 } 00146 00147 function getValidSpecialPages() { 00148 return utf8_decode_array( $this->lang->getValidSpecialPages() ); 00149 } 00150 00151 function getSysopSpecialPages() { 00152 return utf8_decode_array( $this->lang->getSysopSpecialPages() ); 00153 } 00154 00155 function getDeveloperSpecialPages() { 00156 return utf8_decode_array( $this->lang->getDeveloperSpecialPages() ); 00157 } 00158 00159 function getMessage( $key ) { 00160 return utf8_decode( $this->lang->getMessage( $key ) ); 00161 } 00162 00163 function getAllMessages() { 00164 return utf8_decode_array( $this->lang->getAllMessages() ); 00165 } 00166 00167 function iconv( $in, $out, $string ) { 00168 # Use 8-bit version 00169 return Language::iconv( $in, $out, $string ); 00170 } 00171 00172 function ucfirst( $string ) { 00173 # Use 8-bit version 00174 return Language::ucfirst( $string ); 00175 } 00176 00177 function lcfirst( $s ) { 00178 # Use 8-bit version 00179 return Language::lcfirst( $s ); 00180 } 00181 00182 function checkTitleEncoding( $s ) { 00183 # Use 8-bit version 00184 return Language::checkTitleEncoding( $s ); 00185 } 00186 00187 function stripForSearch( $in ) { 00188 # Use 8-bit version 00189 return Language::stripForSearch( $in ); 00190 } 00191 00192 function firstChar( $s ) { 00193 # Use 8-bit version 00194 return Language::firstChar( $s ); 00195 } 00196 00197 function setAltEncoding() { 00198 # Not sure if this should be handled 00199 $this->lang->setAltEncoding(); 00200 } 00201 00202 function recodeForEdit( $s ) { 00203 # Use 8-bit version 00204 return Language::recodeForEdit( $s ); 00205 } 00206 00207 function recodeInput( $s ) { 00208 # Use 8-bit version 00209 return Language::recodeInput( $s ); 00210 } 00211 00212 function isRTL() { 00213 # boolean 00214 return $this->lang->isRTL(); 00215 } 00216 00217 function linkPrefixExtension() { 00218 # boolean 00219 return $this->lang->linkPrefixExtension(); 00220 } 00221 00222 function &getMagicWords() { 00223 return utf8_decode_array( $this->lang->getMagicWords() ); 00224 } 00225 00226 function getMagic( &$mw ) { 00227 # Not sure how to handle this. 00228 # A moot point perhaps as few language files currently 00229 # assign localised magic words, and none of the ones we 00230 # need backwards compatibility for. 00231 return $this->lang->getMagic( $mw ); 00232 } 00233 00234 function emphasize( $text ) { 00235 # It's unlikely that the emphasis markup itself will 00236 # include any non-ASCII chars. 00237 return $this->lang->emphasize( $text ); 00238 } 00239 00240 function formatNum( $number ) { 00241 # Probably not necessary... 00242 return utf8_decode( $this->lang->formatNum( $number ) ); 00243 } 00244 00245 function listToText( $l ) { 00246 # It's unlikely that the list markup itself will 00247 # include any non-ASCII chars. (?) 00248 return $this->lang->listToText( $l ); 00249 } 00250 } 00251 00252 ?>

Generated on Tue Jun 29 23:40:05 2004 for Mediawiki by doxygen 1.3.7