6a2d2009daac951f5a38c78051d5110bcd1fd3cf
7 if( defined( 'MEDIAWIKI' ) ) {
10 # In general you should not make customizations in these language files
11 # directly, but should use the MediaWiki: special namespace to customize
12 # user interface messages through the wiki.
13 # See http://meta.wikipedia.org/wiki/MediaWiki_namespace
15 # NOTE TO TRANSLATORS: Do not copy this whole file when making translations!
16 # A lot of common constants and a base class with inheritable methods are
17 # defined here, which should not be redefined. See the other LanguageXx.php
21 #--------------------------------------------------------------------------
22 # Language-specific text
23 #--------------------------------------------------------------------------
25 if($wgMetaNamespace === FALSE)
26 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
28 /* private */ $wgNamespaceNamesEn = array(
30 NS_SPECIAL
=> 'Special',
34 NS_USER_TALK
=> 'User_talk',
35 NS_PROJECT
=> $wgMetaNamespace,
36 NS_PROJECT_TALK
=> $wgMetaNamespace . '_talk',
38 NS_IMAGE_TALK
=> 'Image_talk',
39 NS_MEDIAWIKI
=> 'MediaWiki',
40 NS_MEDIAWIKI_TALK
=> 'MediaWiki_talk',
41 NS_TEMPLATE
=> 'Template',
42 NS_TEMPLATE_TALK
=> 'Template_talk',
44 NS_HELP_TALK
=> 'Help_talk',
45 NS_CATEGORY
=> 'Category',
46 NS_CATEGORY_TALK
=> 'Category_talk',
49 if(isset($wgExtraNamespaces)) {
50 $wgNamespaceNamesEn=$wgNamespaceNamesEn+
$wgExtraNamespaces;
53 /* private */ $wgDefaultUserOptionsEn = array(
61 'skin' => $wgDefaultSkin,
65 'highlightbroken' => 1,
69 'editsectiononrightclick'=> 0,
75 'rememberpassword' => 0,
76 'enotifwatchlistpages' => 0,
77 'enotifusertalkpages' => 1,
78 'enotifminoredits' => 0,
79 'enotifrevealaddr' => 0,
80 'shownumberswatching' => 1,
82 'externaleditor' => 0,
85 'numberheadings' => 0,
86 'uselivepreview' => 0,
87 'watchlistdays' => 3.0,
90 /* private */ $wgQuickbarSettingsEn = array(
91 'None', 'Fixed left', 'Fixed right', 'Floating left', 'Floating right'
94 /* private */ $wgSkinNamesEn = array(
95 'standard' => 'Classic',
96 'nostalgia' => 'Nostalgia',
97 'cologneblue' => 'Cologne Blue',
98 'davinci' => 'DaVinci',
100 'monobook' => 'MonoBook',
101 'myskin' => 'MySkin',
105 /* private */ $wgMathNamesEn = array(
106 MW_MATH_PNG
=> 'mw_math_png',
107 MW_MATH_SIMPLE
=> 'mw_math_simple',
108 MW_MATH_HTML
=> 'mw_math_html',
109 MW_MATH_SOURCE
=> 'mw_math_source',
110 MW_MATH_MODERN
=> 'mw_math_modern',
111 MW_MATH_MATHML
=> 'mw_math_mathml'
115 * Whether to use user or default setting in Language::date()
117 * NOTE: the array string values are no longer important!
118 * The actual date format functions are now called for the selection in
119 * Special:Preferences, and the 'datedefault' message for MW_DATE_DEFAULT.
121 * The array keys make up the set of formats which this language allows
122 * the user to select. It's exposed via Language::getDateFormats().
126 $wgDateFormatsEn = array(
127 MW_DATE_DEFAULT
=> 'No preference',
128 MW_DATE_DMY
=> '16:12, 15 January 2001',
129 MW_DATE_MDY
=> '16:12, January 15, 2001',
130 MW_DATE_YMD
=> '16:12, 2001 January 15',
131 MW_DATE_ISO
=> '2001-01-15 16:12:34'
134 /* private */ $wgUserTogglesEn = array(
143 'editsectiononrightclick',
153 'enotifwatchlistpages',
154 'enotifusertalkpages',
157 'shownumberswatching',
169 /* private */ $wgBookstoreListEn = array(
170 'AddALL' => 'http://www.addall.com/New/Partner.cgi?query=$1&type=ISBN',
171 'PriceSCAN' => 'http://www.pricescan.com/books/bookDetail.asp?isbn=$1',
172 'Barnes & Noble' => 'http://search.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=$1',
173 'Amazon.com' => 'http://www.amazon.com/exec/obidos/ISBN=$1'
176 # Read language names
177 global $wgLanguageNames;
179 require_once( 'Names.php' );
181 $wgLanguageNamesEn =& $wgLanguageNames;
184 /* private */ $wgWeekdayNamesEn = array(
185 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
190 /* private */ $wgMonthNamesEn = array(
191 'january', 'february', 'march', 'april', 'may_long', 'june',
192 'july', 'august', 'september', 'october', 'november',
195 /* private */ $wgMonthNamesGenEn = array(
196 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
197 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen',
201 /* private */ $wgMonthAbbreviationsEn = array(
202 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
203 'sep', 'oct', 'nov', 'dec'
206 # Note to translators:
207 # Please include the English words as synonyms. This allows people
208 # from other wikis to contribute more easily.
210 /* private */ $wgMagicWordsEn = array(
212 MAG_REDIRECT
=> array( 0, '#REDIRECT' ),
213 MAG_NOTOC
=> array( 0, '__NOTOC__' ),
214 MAG_FORCETOC
=> array( 0, '__FORCETOC__' ),
215 MAG_TOC
=> array( 0, '__TOC__' ),
216 MAG_NOEDITSECTION
=> array( 0, '__NOEDITSECTION__' ),
217 MAG_START
=> array( 0, '__START__' ),
218 MAG_CURRENTMONTH
=> array( 1, 'CURRENTMONTH' ),
219 MAG_CURRENTMONTHNAME
=> array( 1, 'CURRENTMONTHNAME' ),
220 MAG_CURRENTMONTHNAMEGEN
=> array( 1, 'CURRENTMONTHNAMEGEN' ),
221 MAG_CURRENTMONTHABBREV
=> array( 1, 'CURRENTMONTHABBREV' ),
222 MAG_CURRENTDAY
=> array( 1, 'CURRENTDAY' ),
223 MAG_CURRENTDAY2
=> array( 1, 'CURRENTDAY2' ),
224 MAG_CURRENTDAYNAME
=> array( 1, 'CURRENTDAYNAME' ),
225 MAG_CURRENTYEAR
=> array( 1, 'CURRENTYEAR' ),
226 MAG_CURRENTTIME
=> array( 1, 'CURRENTTIME' ),
227 MAG_NUMBEROFARTICLES
=> array( 1, 'NUMBEROFARTICLES' ),
228 MAG_NUMBEROFFILES
=> array( 1, 'NUMBEROFFILES' ),
229 MAG_PAGENAME
=> array( 1, 'PAGENAME' ),
230 MAG_PAGENAMEE
=> array( 1, 'PAGENAMEE' ),
231 MAG_NAMESPACE
=> array( 1, 'NAMESPACE' ),
232 MAG_NAMESPACEE
=> array( 1, 'NAMESPACEE' ),
233 MAG_TALKSPACE
=> array( 1, 'TALKSPACE' ),
234 MAG_TALKSPACEE
=> array( 1, 'TALKSPACEE' ),
235 MAG_SUBJECTSPACE
=> array( 1, 'SUBJECTSPACE', 'ARTICLESPACE' ),
236 MAG_SUBJECTSPACEE
=> array( 1, 'SUBJECTSPACEE', 'ARTICLESPACEE' ),
237 MAG_FULLPAGENAME
=> array( 1, 'FULLPAGENAME' ),
238 MAG_FULLPAGENAMEE
=> array( 1, 'FULLPAGENAMEE' ),
239 MAG_SUBPAGENAME
=> array( 1, 'SUBPAGENAME' ),
240 MAG_SUBPAGENAMEE
=> array( 1, 'SUBPAGENAMEE' ),
241 MAG_TALKPAGENAME
=> array( 1, 'TALKPAGENAME' ),
242 MAG_TALKPAGENAMEE
=> array( 1, 'TALKPAGENAMEE' ),
243 MAG_SUBJECTPAGENAME
=> array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),
244 MAG_SUBJECTPAGENAMEE
=> array( 1, 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ),
245 MAG_MSG
=> array( 0, 'MSG:' ),
246 MAG_SUBST
=> array( 0, 'SUBST:' ),
247 MAG_MSGNW
=> array( 0, 'MSGNW:' ),
248 MAG_END
=> array( 0, '__END__' ),
249 MAG_IMG_THUMBNAIL
=> array( 1, 'thumbnail', 'thumb' ),
250 MAG_IMG_MANUALTHUMB
=> array( 1, 'thumbnail=$1', 'thumb=$1'),
251 MAG_IMG_RIGHT
=> array( 1, 'right' ),
252 MAG_IMG_LEFT
=> array( 1, 'left' ),
253 MAG_IMG_NONE
=> array( 1, 'none' ),
254 MAG_IMG_WIDTH
=> array( 1, '$1px' ),
255 MAG_IMG_CENTER
=> array( 1, 'center', 'centre' ),
256 MAG_IMG_FRAMED
=> array( 1, 'framed', 'enframed', 'frame' ),
257 MAG_INT
=> array( 0, 'INT:' ),
258 MAG_SITENAME
=> array( 1, 'SITENAME' ),
259 MAG_NS
=> array( 0, 'NS:' ),
260 MAG_LOCALURL
=> array( 0, 'LOCALURL:' ),
261 MAG_LOCALURLE
=> array( 0, 'LOCALURLE:' ),
262 MAG_SERVER
=> array( 0, 'SERVER' ),
263 MAG_SERVERNAME
=> array( 0, 'SERVERNAME' ),
264 MAG_SCRIPTPATH
=> array( 0, 'SCRIPTPATH' ),
265 MAG_GRAMMAR
=> array( 0, 'GRAMMAR:' ),
266 MAG_NOTITLECONVERT
=> array( 0, '__NOTITLECONVERT__', '__NOTC__'),
267 MAG_NOCONTENTCONVERT
=> array( 0, '__NOCONTENTCONVERT__', '__NOCC__'),
268 MAG_CURRENTWEEK
=> array( 1, 'CURRENTWEEK' ),
269 MAG_CURRENTDOW
=> array( 1, 'CURRENTDOW' ),
270 MAG_REVISIONID
=> array( 1, 'REVISIONID' ),
271 MAG_PLURAL
=> array( 0, 'PLURAL:' ),
272 MAG_FULLURL
=> array( 0, 'FULLURL:' ),
273 MAG_FULLURLE
=> array( 0, 'FULLURLE:' ),
274 MAG_LCFIRST
=> array( 0, 'LCFIRST:' ),
275 MAG_UCFIRST
=> array( 0, 'UCFIRST:' ),
276 MAG_LC
=> array( 0, 'LC:' ),
277 MAG_UC
=> array( 0, 'UC:' ),
278 MAG_RAW
=> array( 0, 'RAW:' ),
279 MAG_DISPLAYTITLE
=> array( 1, 'DISPLAYTITLE' ),
282 if (!$wgCachedMessageArrays) {
283 require_once('Messages.php');
286 /* a fake language converter */
287 class fakeConverter
{
289 function fakeConverter($langobj) {$this->mLang
= $langobj;}
290 function convert($t, $i) {return $t;}
291 function parserConvert($t, $p) {return $t;}
292 function getVariants() { return array( $this->mLang
->getCode() ); }
293 function getPreferredVariant() {return $this->mLang
->getCode(); }
294 function findVariantLink(&$l, &$n) {}
295 function getExtraHashOptions() {return '';}
296 function getParsedTitle() {return '';}
297 function markNoConversion($text) {return $text;}
298 function convertCategoryKey( $key ) {return $key; }
302 #--------------------------------------------------------------------------
303 # Internationalisation code
304 #--------------------------------------------------------------------------
308 function Language() {
310 # Copies any missing values in the specified arrays from En to the current language
311 $fillin = array( 'wgSysopSpecialPages', 'wgValidSpecialPages', 'wgDeveloperSpecialPages' );
312 $name = get_class( $this );
314 if( strpos( $name, 'language' ) == 0){
315 $lang = ucfirst( substr( $name, 8 ) );
316 foreach( $fillin as $arrname ){
317 $langver = "{$arrname}{$lang}";
318 $enver = "{$arrname}En";
319 if( ! isset( $GLOBALS[$langver] ) ||
! isset( $GLOBALS[$enver] ))
321 foreach($GLOBALS[$enver] as $spage => $text){
322 if( ! isset( $GLOBALS[$langver][$spage] ) )
323 $GLOBALS[$langver][$spage] = $text;
327 $this->mConverter
= new fakeConverter($this);
331 * Exports the default user options as defined in
332 * $wgDefaultUserOptionsEn, user preferences can override some of these
333 * depending on what's in (Local|Default)Settings.php and some defines.
337 function getDefaultUserOptions() {
338 global $wgDefaultUserOptionsEn ;
339 return $wgDefaultUserOptionsEn ;
343 * Exports $wgBookstoreListEn
346 function getBookstoreList() {
347 global $wgBookstoreListEn ;
348 return $wgBookstoreListEn ;
354 function getNamespaces() {
355 global $wgNamespaceNamesEn;
356 return $wgNamespaceNamesEn;
360 * A convenience function that returns the same thing as
361 * getNamespaces() except with the array values changed to ' '
362 * where it found '_', useful for producing output to be displayed
363 * e.g. in <select> forms.
367 function getFormattedNamespaces() {
368 $ns = $this->getNamespaces();
369 foreach($ns as $k => $v) {
370 $ns[$k] = strtr($v, '_', ' ');
376 * Get a namespace value by key
378 * $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI );
379 * echo $mw_ns; // prints 'MediaWiki'
382 * @param int $index the array key of the namespace to return
383 * @return mixed, string if the namespace value exists, otherwise false
385 function getNsText( $index ) {
386 $ns = $this->getNamespaces();
387 return isset( $ns[$index] ) ?
$ns[$index] : false;
391 * A convenience function that returns the same thing as
392 * getNsText() except with '_' changed to ' ', useful for
397 function getFormattedNsText( $index ) {
398 $ns = $this->getNsText( $index );
399 return strtr($ns, '_', ' ');
403 * Get a namespace key by value, case insensetive.
405 * @param string $text
406 * @return mixed An integer if $text is a valid value otherwise false
408 function getNsIndex( $text ) {
409 $ns = $this->getNamespaces();
411 foreach ( $ns as $i => $n ) {
412 if ( strcasecmp( $n, $text ) == 0)
419 * short names for language variants used for language conversion links.
421 * @param string $code
424 function getVariantname( $code ) {
425 return wfMsg( "variantname-$code" );
428 function specialPage( $name ) {
429 return $this->getNsText(NS_SPECIAL
) . ':' . $name;
432 function getQuickbarSettings() {
433 global $wgQuickbarSettingsEn;
434 return $wgQuickbarSettingsEn;
437 function getSkinNames() {
438 global $wgSkinNamesEn;
439 return $wgSkinNamesEn;
442 function getMathNames() {
443 global $wgMathNamesEn;
444 return $wgMathNamesEn;
447 function getDateFormats() {
448 global $wgDateFormatsEn;
449 return $wgDateFormatsEn;
452 function getUserToggles() {
453 global $wgUserTogglesEn;
454 return $wgUserTogglesEn;
457 function getUserToggle( $tog ) {
458 return wfMsg( "tog-$tog" );
461 function getLanguageNames() {
462 global $wgLanguageNamesEn;
463 return $wgLanguageNamesEn;
466 function getLanguageName( $code ) {
467 global $wgLanguageNamesEn;
468 if ( ! array_key_exists( $code, $wgLanguageNamesEn ) ) {
471 return $wgLanguageNamesEn[$code];
474 function getMonthName( $key ) {
475 global $wgMonthNamesEn, $wgContLang;
476 // see who called us and use the correct message function
477 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
478 return wfMsgForContent($wgMonthNamesEn[$key-1]);
480 return wfMsg($wgMonthNamesEn[$key-1]);
483 /* by default we just return base form */
484 function getMonthNameGen( $key ) {
485 return $this->getMonthName( $key );
488 function getMonthAbbreviation( $key ) {
489 global $wgMonthAbbreviationsEn, $wgContLang;
490 // see who called us and use the correct message function
491 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
492 return wfMsgForContent(@$wgMonthAbbreviationsEn[$key-1]);
494 return wfMsg(@$wgMonthAbbreviationsEn[$key-1]);
497 function getWeekdayName( $key ) {
498 global $wgWeekdayNamesEn, $wgContLang;
499 // see who called us and use the correct message function
500 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
501 return wfMsgForContent($wgWeekdayNamesEn[$key-1]);
503 return wfMsg($wgWeekdayNamesEn[$key-1]);
507 * Used by date() and time() to adjust the time output.
509 * @param int $ts the time in date('YmdHis') format
510 * @param mixed $tz adjust the time by this amount (default false)
514 function userAdjust( $ts, $tz = false ) {
515 global $wgUser, $wgLocalTZoffset;
518 $tz = $wgUser->getOption( 'timecorrection' );
522 $hrDiff = isset( $wgLocalTZoffset ) ?
$wgLocalTZoffset : 0;
524 } elseif ( strpos( $tz, ':' ) !== false ) {
525 $tzArray = explode( ':', $tz );
526 $hrDiff = intval($tzArray[0]);
527 $minDiff = intval($hrDiff < 0 ?
-$tzArray[1] : $tzArray[1]);
529 $hrDiff = intval( $tz );
531 if ( 0 == $hrDiff && 0 == $minDiff ) { return $ts; }
534 (int)substr( $ts, 8, 2) ) +
$hrDiff, # Hours
535 (int)substr( $ts, 10, 2 ) +
$minDiff, # Minutes
536 (int)substr( $ts, 12, 2 ), # Seconds
537 (int)substr( $ts, 4, 2 ), # Month
538 (int)substr( $ts, 6, 2 ), # Day
539 (int)substr( $ts, 0, 4 ) ); #Year
540 return date( 'YmdHis', $t );
544 * This is meant to be used by time(), date(), and timeanddate() to get
545 * the date preference they're supposed to use, it should be used in
549 * function timeanddate([...], $format = true) {
550 * $datePreference = $this->dateFormat($format);
554 * @param mixed $usePrefs: if true, the user's preference is used
555 * if false, the site/language default is used
556 * if int/string, assumed to be a format.
559 function dateFormat( $usePrefs = true ) {
562 if( is_bool( $usePrefs ) ) {
564 $datePreference = $wgUser->getOption( 'date' );
566 $options = $this->getDefaultUserOptions();
567 $datePreference = (string)$options['date'];
570 $datePreference = (string)$usePrefs;
574 if( $datePreference == '' ) {
575 return MW_DATE_DEFAULT
;
578 return $datePreference;
583 * @param mixed $ts the time format which needs to be turned into a
584 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
585 * @param bool $adj whether to adjust the time output according to the
586 * user configured offset ($timecorrection)
587 * @param mixed $format true to use user's date format preference
588 * @param string $timecorrection the time offset as returned by
589 * validateTimeZone() in Special:Preferences
592 function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
593 global $wgUser, $wgAmericanDates;
595 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
597 $datePreference = $this->dateFormat( $format );
598 if( $datePreference == MW_DATE_DEFAULT
) {
599 $datePreference = $wgAmericanDates ? MW_DATE_MDY
: MW_DATE_DMY
;
602 $month = $this->formatMonth( substr( $ts, 4, 2 ), $datePreference );
603 $day = $this->formatDay( substr( $ts, 6, 2 ), $datePreference );
604 $year = $this->formatNum( substr( $ts, 0, 4 ), true );
606 switch( $datePreference ) {
607 case MW_DATE_DMY
: return "$day $month $year";
608 case MW_DATE_YMD
: return "$year $month $day";
609 case MW_DATE_ISO
: return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
610 default: return "$month $day, $year";
616 * @param mixed $ts the time format which needs to be turned into a
617 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
618 * @param bool $adj whether to adjust the time output according to the
619 * user configured offset ($timecorrection)
620 * @param mixed $format true to use user's date format preference
621 * @param string $timecorrection the time offset as returned by
622 * validateTimeZone() in Special:Preferences
625 function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
628 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
629 $datePreference = $this->dateFormat( $format );
631 $sep = ($datePreference == MW_DATE_ISO
)
633 : $this->timeSeparator( $format );
635 $t = substr( $ts, 8, 2 ) . $sep . substr( $ts, 10, 2 );
637 if ( $datePreference == MW_DATE_ISO
) {
638 $t .= $sep . substr( $ts, 12, 2 );
644 * Default separator character between hours, minutes, and seconds.
645 * Will be used by Language::time() for non-ISO formats.
646 * (ISO will always use a colon.)
649 function timeSeparator( $format ) {
654 * String to insert between the time and the date in a combined
655 * string. Should include any relevant whitespace.
658 function timeDateSeparator( $format ) {
663 * Return true if the time should display before the date.
667 function timeBeforeDate() {
671 function formatMonth( $month, $format ) {
672 return $this->getMonthName( $month );
675 function formatDay( $day, $format ) {
676 return $this->formatNum( 0 +
$day );
681 * @param mixed $ts the time format which needs to be turned into a
682 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
683 * @param bool $adj whether to adjust the time output according to the
684 * user configured offset ($timecorrection)
686 * @param mixed $format what format to return, if it's false output the
687 * default one (default true)
688 * @param string $timecorrection the time offset as returned by
689 * validateTimeZone() in Special:Preferences
692 function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
695 $datePreference = $this->dateFormat($format);
696 switch ( $datePreference ) {
697 case MW_DATE_ISO
: return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
698 $this->time( $ts, $adj, $format, $timecorrection );
700 $time = $this->time( $ts, $adj, $format, $timecorrection );
701 $sep = $this->timeDateSeparator( $datePreference );
702 $date = $this->date( $ts, $adj, $format, $timecorrection );
703 return $this->timeBeforeDate( $datePreference )
704 ?
$time . $sep . $date
705 : $date . $sep . $time;
709 function getMessage( $key ) {
710 global $wgAllMessagesEn;
711 return @$wgAllMessagesEn[$key];
714 function getAllMessages() {
715 global $wgAllMessagesEn;
716 return $wgAllMessagesEn;
719 function iconv( $in, $out, $string ) {
720 # For most languages, this is a wrapper for iconv
721 return iconv( $in, $out, $string );
724 function ucfirst( $string ) {
725 # For most languages, this is a wrapper for ucfirst()
726 return ucfirst( $string );
729 function uc( $str ) {
730 return strtoupper( $str );
733 function lcfirst( $s ) {
734 return strtolower( $s{0} ). substr( $s, 1 );
737 function lc( $str ) {
738 return strtolower( $str );
741 function checkTitleEncoding( $s ) {
742 global $wgInputEncoding;
744 # Check for UTF-8 URLs; Internet Explorer produces these if you
745 # type non-ASCII chars in the URL bar or follow unescaped links.
746 $ishigh = preg_match( '/[\x80-\xff]/', $s);
747 $isutf = ($ishigh ?
preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
748 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true );
750 if( ($wgInputEncoding != 'utf-8') and $ishigh and $isutf )
751 return @iconv
( 'UTF-8', $wgInputEncoding, $s );
753 if( ($wgInputEncoding == 'utf-8') and $ishigh and !$isutf )
754 return utf8_encode( $s );
756 # Other languages can safely leave this function, or replace
757 # it with one to detect and convert another legacy encoding.
762 * Some languages have special punctuation to strip out
763 * or characters which need to be converted for MySQL's
764 * indexing to grok it correctly. Make such changes here.
769 function stripForSearch( $in ) {
770 return strtolower( $in );
773 function convertForSearchResult( $termsArray ) {
774 # some languages, e.g. Chinese, need to do a conversion
775 # in order for search results to be displayed correctly
780 * Get the first character of a string. In ASCII, return
781 * first byte of the string. UTF8 and others have to
787 function firstChar( $s ) {
791 function initEncoding() {
792 # Some languages may have an alternate char encoding option
793 # (Esperanto X-coding, Japanese furigana conversion, etc)
794 # If this language is used as the primary content language,
795 # an override to the defaults can be set here on startup.
796 #global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
799 function setAltEncoding() {
800 # Some languages may have an alternate char encoding option
801 # (Esperanto X-coding, Japanese furigana conversion, etc)
802 # If 'altencoding' is checked in user prefs, this gives a
803 # chance to swap out the default encoding settings.
804 #global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
807 function recodeForEdit( $s ) {
808 # For some languages we'll want to explicitly specify
809 # which characters make it into the edit box raw
810 # or are converted in some way or another.
811 # Note that if wgOutputEncoding is different from
812 # wgInputEncoding, this text will be further converted
813 # to wgOutputEncoding.
814 global $wgInputEncoding, $wgEditEncoding;
815 if( $wgEditEncoding == '' or
816 $wgEditEncoding == $wgInputEncoding ) {
819 return $this->iconv( $wgInputEncoding, $wgEditEncoding, $s );
823 function recodeInput( $s ) {
824 # Take the previous into account.
825 global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
826 if($wgEditEncoding != "") {
827 $enc = $wgEditEncoding;
829 $enc = $wgOutputEncoding;
831 if( $enc == $wgInputEncoding ) {
834 return $this->iconv( $enc, $wgInputEncoding, $s );
839 * For right-to-left language support
843 function isRTL() { return false; }
846 * To allow "foo[[bar]]" to extend the link over the whole word "foobar"
850 function linkPrefixExtension() { return false; }
853 function &getMagicWords() {
854 global $wgMagicWordsEn;
855 return $wgMagicWordsEn;
858 # Fill a MagicWord object with data from here
859 function getMagic( &$mw ) {
860 $raw = $this->getMagicWords();
862 wfRunHooks( 'LanguageGetMagic', array( &$raw ) );
864 if( !isset( $raw[$mw->mId
] ) ) {
865 # Fall back to English if local list is incomplete
866 $raw =& Language
::getMagicWords();
868 $rawEntry = $raw[$mw->mId
];
869 $mw->mCaseSensitive
= $rawEntry[0];
870 $mw->mSynonyms
= array_slice( $rawEntry, 1 );
874 * Italic is unsuitable for some languages
878 * @param string $text The text to be emphasized.
881 function emphasize( $text ) {
882 return "<em>$text</em>";
886 * This function enables formatting of numbers, it should only come
887 * into effect when the $wgTranslateNumerals variable is TRUE.
889 * Normally we output all numbers in plain en_US style, that is
890 * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
891 * point twohundredthirtyfive. However this is not sutable for all
892 * languages, some such as Pakaran want ੨੯੩,੨੯੫.੨੩੫ and others such as
893 * Icelandic just want to use commas instead of dots, and dots instead
894 * of commas like "293.291,235".
896 * An example of this function being called:
898 * wfMsg( 'message', $wgLang->formatNum( $num ) )
901 * See LanguageGu.php for the Gujarati implementation and
902 * LanguageIs.php for the , => . and . => , implementation.
904 * @todo check if it's viable to use localeconv() for the decimal
907 * @param mixed $number the string to be formatted, should be an integer or
908 * a floating point number.
909 * @param bool $year are we being passed a year? (turns off commafication)
910 * @return mixed whatever we're fed if it's a year, a string otherwise.
912 function formatNum( $number, $year = false ) {
913 return $year ?
$number : $this->commafy($number);
917 * Adds commas to a given number
922 function commafy($_) {
923 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
927 * For the credit list in includes/Credits.php (action=credits)
932 function listToText( $l ) {
935 for ($i = $m; $i >= 0; $i--) {
938 } else if ($i == $m - 1) {
939 $s = $l[$i] . ' ' . wfMsg('and') . ' ' . $s;
941 $s = $l[$i] . ', ' . $s;
947 # Crop a string from the beginning or end to a certain number of bytes.
948 # (Bytes are used because our storage has limited byte lengths for some
949 # columns in the database.) Multibyte charsets will need to make sure that
950 # only whole characters are included!
952 # $length does not include the optional ellipsis.
953 # If $length is negative, snip from the beginning
954 function truncate( $string, $length, $ellipsis = '' ) {
958 if ( strlen( $string ) <= abs( $length ) ) {
962 $string = substr( $string, 0, $length );
963 return $string . $ellipsis;
965 $string = substr( $string, $length );
966 return $ellipsis . $string;
971 * Grammatical transformations, needed for inflected languages
972 * Invoked by putting {{grammar:case|word}} in a message
974 * @param string $word
975 * @param string $case
978 function convertGrammar( $word, $case ) {
983 * Plural form transformations, needed for some languages.
984 * For example, where are 3 form of plural in Russian and Polish,
985 * depending on "count mod 10". See [[w:Plural]]
986 * For English it is pretty simple.
988 * Invoked by putting {{plural:count|wordform1|wordform2}}
989 * or {{plural:count|wordform1|wordform2|wordform3}}
991 * Example: {{plural:{{NUMBEROFARTICLES}}|article|articles}}
993 * @param integer $count
994 * @param string $wordform1
995 * @param string $wordform2
996 * @param string $wordform3 (optional)
999 function convertPlural( $count, $wordform1, $wordform2, $wordform3) {
1000 return $count == '1' ?
$wordform1 : $wordform2;
1004 * For translaing of expiry times
1005 * @param string The validated block time in English
1006 * @return Somehow translated block time
1007 * @see LanguageFi.php for example implementation
1009 function translateBlockExpiry( $str ) {
1011 $scBlockExpiryOptions = wfMsg( 'ipboptions' );
1013 if ( $scBlockExpiryOptions == '-') {
1017 foreach (explode(',', $scBlockExpiryOptions) as $option) {
1018 if ( strpos($option, ":") === false )
1020 list($show, $value) = explode(":", $option);
1021 if ( strcmp ( $str, $value) == 0 )
1022 return '<span title="' . htmlspecialchars($str). '">' .
1023 htmlspecialchars( trim( $show ) ) . '</span>';
1030 * languages like Chinese need to be segmented in order for the diff
1033 * @param string $text
1036 function segmentForDiff( $text ) {
1041 * and unsegment to show the result
1043 * @param string $text
1046 function unsegmentForDiff( $text ) {
1050 # convert text to different variants of a language.
1051 function convert( $text, $isTitle = false) {
1052 return $this->mConverter
->convert($text, $isTitle);
1055 # Convert text from within Parser
1056 function parserConvert( $text, &$parser ) {
1057 return $this->mConverter
->parserConvert( $text, $parser );
1061 * Perform output conversion on a string, and encode for safe HTML output.
1062 * @param string $text
1063 * @param bool $isTitle -- wtf?
1065 * @todo this should get integrated somewhere sane
1067 function convertHtml( $text, $isTitle = false ) {
1068 return htmlspecialchars( $this->convert( $text, $isTitle ) );
1071 function convertCategoryKey( $key ) {
1072 return $this->mConverter
->convertCategoryKey( $key );
1076 * get the list of variants supported by this langauge
1077 * see sample implementation in LanguageZh.php
1079 * @return array an array of language codes
1081 function getVariants() {
1082 return $this->mConverter
->getVariants();
1086 function getPreferredVariant() {
1087 return $this->mConverter
->getPreferredVariant();
1091 * if a language supports multiple variants, it is
1092 * possible that non-existing link in one variant
1093 * actually exists in another variant. this function
1094 * tries to find it. See e.g. LanguageZh.php
1096 * @param string $link the name of the link
1097 * @param mixed $nt the title object of the link
1098 * @return null the input parameters may be modified upon return
1100 function findVariantLink( &$link, &$nt ) {
1101 $this->mConverter
->findVariantLink($link, $nt);
1105 * returns language specific options used by User::getPageRenderHash()
1106 * for example, the preferred language variant
1111 function getExtraHashOptions() {
1112 return $this->mConverter
->getExtraHashOptions();
1116 * for languages that support multiple variants, the title of an
1117 * article may be displayed differently in different variants. this
1118 * function returns the apporiate title defined in the body of the article.
1122 function getParsedTitle() {
1123 return $this->mConverter
->getParsedTitle();
1127 * Enclose a string with the "no conversion" tag. This is used by
1128 * various functions in the Parser
1130 * @param string $text text to be tagged for no conversion
1131 * @return string the tagged text
1133 function markNoConversion( $text ) {
1134 return $this->mConverter
->markNoConversion( $text );
1138 * A regular expression to match legal word-trailing characters
1139 * which should be merged onto a link of the form [[foo]]bar.
1144 function linkTrail() {
1145 return $this->getMessage( 'linktrail' );
1148 function getLangObj() {
1153 * Get the RFC 3066 code for this language object
1155 function getCode() {
1156 return str_replace( '_', '-', strtolower( substr( get_class( $this ), 8 ) ) );
1162 # FIXME: Merge all UTF-8 support code into Language base class.
1163 # We no longer support Latin-1 charset.
1164 require_once( 'LanguageUtf8.php' );
1166 # This should fail gracefully if there's not a localization available
1167 wfSuppressWarnings();
1168 // Preload base classes to work around APC/PHP5 bug
1169 include_once( 'Language' . str_replace( '-', '_', ucfirst( $wgLanguageCode ) ) . '.deps.php' );
1170 include_once( 'Language' . str_replace( '-', '_', ucfirst( $wgLanguageCode ) ) . '.php' );
1171 wfRestoreWarnings();