New DISPLAYTITLE magic template; decativated by default so not to scare Brion
[lhc/web/wiklou.git] / languages / Language.php
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage Language
5 */
6
7 if( defined( 'MEDIAWIKI' ) ) {
8
9 #
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
14 #
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
18 # files for examples.
19 #
20
21 #--------------------------------------------------------------------------
22 # Language-specific text
23 #--------------------------------------------------------------------------
24
25 if($wgMetaNamespace === FALSE)
26 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
27
28 /* private */ $wgNamespaceNamesEn = array(
29 NS_MEDIA => 'Media',
30 NS_SPECIAL => 'Special',
31 NS_MAIN => '',
32 NS_TALK => 'Talk',
33 NS_USER => 'User',
34 NS_USER_TALK => 'User_talk',
35 NS_PROJECT => $wgMetaNamespace,
36 NS_PROJECT_TALK => $wgMetaNamespace . '_talk',
37 NS_IMAGE => 'Image',
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',
43 NS_HELP => 'Help',
44 NS_HELP_TALK => 'Help_talk',
45 NS_CATEGORY => 'Category',
46 NS_CATEGORY_TALK => 'Category_talk',
47 );
48
49 if(isset($wgExtraNamespaces)) {
50 $wgNamespaceNamesEn=$wgNamespaceNamesEn+$wgExtraNamespaces;
51 }
52
53 /* private */ $wgDefaultUserOptionsEn = array(
54 'quickbar' => 1,
55 'underline' => 2,
56 'cols' => 80,
57 'rows' => 25,
58 'searchlimit' => 20,
59 'contextlines' => 5,
60 'contextchars' => 50,
61 'skin' => $wgDefaultSkin,
62 'math' => 1,
63 'rcdays' => 7,
64 'rclimit' => 50,
65 'highlightbroken' => 1,
66 'stubthreshold' => 0,
67 'previewontop' => 1,
68 'editsection' => 1,
69 'editsectiononrightclick'=> 0,
70 'showtoc' => 1,
71 'showtoolbar' => 1,
72 'date' => 0,
73 'imagesize' => 2,
74 'thumbsize' => 2,
75 'rememberpassword' => 0,
76 'enotifwatchlistpages' => 0,
77 'enotifusertalkpages' => 1,
78 'enotifminoredits' => 0,
79 'enotifrevealaddr' => 0,
80 'shownumberswatching' => 1,
81 'fancysig' => 0,
82 'externaleditor' => 0,
83 'externaldiff' => 0,
84 'showjumplinks' => 1,
85 'numberheadings' => 0,
86 'uselivepreview' => 0,
87 );
88
89 /* private */ $wgQuickbarSettingsEn = array(
90 'None', 'Fixed left', 'Fixed right', 'Floating left', 'Floating right'
91 );
92
93 /* private */ $wgSkinNamesEn = array(
94 'standard' => 'Classic',
95 'nostalgia' => 'Nostalgia',
96 'cologneblue' => 'Cologne Blue',
97 'davinci' => 'DaVinci',
98 'mono' => 'Mono',
99 'monobook' => 'MonoBook',
100 'myskin' => 'MySkin',
101 'chick' => 'Chick'
102 );
103
104 /* private */ $wgMathNamesEn = array(
105 MW_MATH_PNG => 'mw_math_png',
106 MW_MATH_SIMPLE => 'mw_math_simple',
107 MW_MATH_HTML => 'mw_math_html',
108 MW_MATH_SOURCE => 'mw_math_source',
109 MW_MATH_MODERN => 'mw_math_modern',
110 MW_MATH_MATHML => 'mw_math_mathml'
111 );
112
113 /**
114 * Whether to use user or default setting in Language::date()
115 *
116 * NOTE: the array string values are no longer important!
117 * The actual date format functions are now called for the selection in
118 * Special:Preferences, and the 'datedefault' message for MW_DATE_DEFAULT.
119 *
120 * The array keys make up the set of formats which this language allows
121 * the user to select. It's exposed via Language::getDateFormats().
122 *
123 * @access private
124 */
125 $wgDateFormatsEn = array(
126 MW_DATE_DEFAULT => 'No preference',
127 MW_DATE_DMY => '16:12, 15 January 2001',
128 MW_DATE_MDY => '16:12, January 15, 2001',
129 MW_DATE_YMD => '16:12, 2001 January 15',
130 MW_DATE_ISO => '2001-01-15 16:12:34'
131 );
132
133 /* private */ $wgUserTogglesEn = array(
134 'highlightbroken',
135 'justify',
136 'hideminor',
137 'usenewrc',
138 'numberheadings',
139 'showtoolbar',
140 'editondblclick',
141 'editsection',
142 'editsectiononrightclick',
143 'showtoc',
144 'rememberpassword',
145 'editwidth',
146 'watchcreations',
147 'watchdefault',
148 'minordefault',
149 'previewontop',
150 'previewonfirst',
151 'nocache',
152 'enotifwatchlistpages',
153 'enotifusertalkpages',
154 'enotifminoredits',
155 'enotifrevealaddr',
156 'shownumberswatching',
157 'fancysig',
158 'externaleditor',
159 'externaldiff',
160 'showjumplinks',
161 'uselivepreview',
162 'autopatrol',
163 'forceeditsummary',
164 );
165
166 /* private */ $wgBookstoreListEn = array(
167 'AddALL' => 'http://www.addall.com/New/Partner.cgi?query=$1&type=ISBN',
168 'PriceSCAN' => 'http://www.pricescan.com/books/bookDetail.asp?isbn=$1',
169 'Barnes & Noble' => 'http://search.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=$1',
170 'Amazon.com' => 'http://www.amazon.com/exec/obidos/ISBN=$1'
171 );
172
173 # Read language names
174 global $wgLanguageNames;
175 /** */
176 require_once( 'Names.php' );
177
178 $wgLanguageNamesEn =& $wgLanguageNames;
179
180
181 /* private */ $wgWeekdayNamesEn = array(
182 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
183 'friday', 'saturday'
184 );
185
186
187 /* private */ $wgMonthNamesEn = array(
188 'january', 'february', 'march', 'april', 'may_long', 'june',
189 'july', 'august', 'september', 'october', 'november',
190 'december'
191 );
192 /* private */ $wgMonthNamesGenEn = array(
193 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
194 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen',
195 'december-gen'
196 );
197
198 /* private */ $wgMonthAbbreviationsEn = array(
199 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
200 'sep', 'oct', 'nov', 'dec'
201 );
202
203 # Note to translators:
204 # Please include the English words as synonyms. This allows people
205 # from other wikis to contribute more easily.
206 #
207 /* private */ $wgMagicWordsEn = array(
208 # ID CASE SYNONYMS
209 MAG_REDIRECT => array( 0, '#REDIRECT' ),
210 MAG_NOTOC => array( 0, '__NOTOC__' ),
211 MAG_FORCETOC => array( 0, '__FORCETOC__' ),
212 MAG_TOC => array( 0, '__TOC__' ),
213 MAG_NOEDITSECTION => array( 0, '__NOEDITSECTION__' ),
214 MAG_START => array( 0, '__START__' ),
215 MAG_CURRENTMONTH => array( 1, 'CURRENTMONTH' ),
216 MAG_CURRENTMONTHNAME => array( 1, 'CURRENTMONTHNAME' ),
217 MAG_CURRENTMONTHNAMEGEN => array( 1, 'CURRENTMONTHNAMEGEN' ),
218 MAG_CURRENTMONTHABBREV => array( 1, 'CURRENTMONTHABBREV' ),
219 MAG_CURRENTDAY => array( 1, 'CURRENTDAY' ),
220 MAG_CURRENTDAY2 => array( 1, 'CURRENTDAY2' ),
221 MAG_CURRENTDAYNAME => array( 1, 'CURRENTDAYNAME' ),
222 MAG_CURRENTYEAR => array( 1, 'CURRENTYEAR' ),
223 MAG_CURRENTTIME => array( 1, 'CURRENTTIME' ),
224 MAG_NUMBEROFARTICLES => array( 1, 'NUMBEROFARTICLES' ),
225 MAG_NUMBEROFFILES => array( 1, 'NUMBEROFFILES' ),
226 MAG_PAGENAME => array( 1, 'PAGENAME' ),
227 MAG_PAGENAMEE => array( 1, 'PAGENAMEE' ),
228 MAG_NAMESPACE => array( 1, 'NAMESPACE' ),
229 MAG_NAMESPACEE => array( 1, 'NAMESPACEE' ),
230 MAG_FULLPAGENAME => array( 1, 'FULLPAGENAME' ),
231 MAG_FULLPAGENAMEE => array( 1, 'FULLPAGENAMEE' ),
232 MAG_SUBPAGENAME => array( 0, 'SUBPAGENAME' ),
233 MAG_SUBPAGENAMEE => array( 0, 'SUBPAGENAMEE' ),
234 MAG_MSG => array( 0, 'MSG:' ),
235 MAG_SUBST => array( 0, 'SUBST:' ),
236 MAG_MSGNW => array( 0, 'MSGNW:' ),
237 MAG_END => array( 0, '__END__' ),
238 MAG_IMG_THUMBNAIL => array( 1, 'thumbnail', 'thumb' ),
239 MAG_IMG_MANUALTHUMB => array( 1, 'thumbnail=$1', 'thumb=$1'),
240 MAG_IMG_RIGHT => array( 1, 'right' ),
241 MAG_IMG_LEFT => array( 1, 'left' ),
242 MAG_IMG_NONE => array( 1, 'none' ),
243 MAG_IMG_WIDTH => array( 1, '$1px' ),
244 MAG_IMG_CENTER => array( 1, 'center', 'centre' ),
245 MAG_IMG_FRAMED => array( 1, 'framed', 'enframed', 'frame' ),
246 MAG_INT => array( 0, 'INT:' ),
247 MAG_SITENAME => array( 1, 'SITENAME' ),
248 MAG_NS => array( 0, 'NS:' ),
249 MAG_LOCALURL => array( 0, 'LOCALURL:' ),
250 MAG_LOCALURLE => array( 0, 'LOCALURLE:' ),
251 MAG_SERVER => array( 0, 'SERVER' ),
252 MAG_SERVERNAME => array( 0, 'SERVERNAME' ),
253 MAG_SCRIPTPATH => array( 0, 'SCRIPTPATH' ),
254 MAG_GRAMMAR => array( 0, 'GRAMMAR:' ),
255 MAG_NOTITLECONVERT => array( 0, '__NOTITLECONVERT__', '__NOTC__'),
256 MAG_NOCONTENTCONVERT => array( 0, '__NOCONTENTCONVERT__', '__NOCC__'),
257 MAG_CURRENTWEEK => array( 1, 'CURRENTWEEK' ),
258 MAG_CURRENTDOW => array( 1, 'CURRENTDOW' ),
259 MAG_REVISIONID => array( 1, 'REVISIONID' ),
260 MAG_PLURAL => array( 0, 'PLURAL:' ),
261 MAG_FULLURL => array( 0, 'FULLURL:' ),
262 MAG_FULLURLE => array( 0, 'FULLURLE:' ),
263 MAG_LCFIRST => array( 0, 'LCFIRST:' ),
264 MAG_UCFIRST => array( 0, 'UCFIRST:' ),
265 MAG_LC => array( 0, 'LC:' ),
266 MAG_UC => array( 0, 'UC:' ),
267 MAG_RAW => array( 0, 'RAW:' ),
268 MAG_DISPLAYTITLE => array( 1, 'DISPLAYTITLE' ),
269 );
270
271 if (!$wgCachedMessageArrays) {
272 require_once('Messages.php');
273 }
274
275 /* a fake language converter */
276 class fakeConverter {
277 var $mLang;
278 function fakeConverter($langobj) {$this->mLang = $langobj;}
279 function convert($t, $i) {return $t;}
280 function parserConvert($t, $p) {return $t;}
281 function getVariants() { return array( $this->mLang->getCode() ); }
282 function getPreferredVariant() {return $this->mLang->getCode(); }
283 function findVariantLink(&$l, &$n) {}
284 function getExtraHashOptions() {return '';}
285 function getParsedTitle() {return '';}
286 function markNoConversion($text) {return $text;}
287 function convertCategoryKey( $key ) {return $key; }
288
289 }
290
291 #--------------------------------------------------------------------------
292 # Internationalisation code
293 #--------------------------------------------------------------------------
294
295 class Language {
296 var $mConverter;
297 function Language() {
298
299 # Copies any missing values in the specified arrays from En to the current language
300 $fillin = array( 'wgSysopSpecialPages', 'wgValidSpecialPages', 'wgDeveloperSpecialPages' );
301 $name = get_class( $this );
302
303 if( strpos( $name, 'language' ) == 0){
304 $lang = ucfirst( substr( $name, 8 ) );
305 foreach( $fillin as $arrname ){
306 $langver = "{$arrname}{$lang}";
307 $enver = "{$arrname}En";
308 if( ! isset( $GLOBALS[$langver] ) || ! isset( $GLOBALS[$enver] ))
309 continue;
310 foreach($GLOBALS[$enver] as $spage => $text){
311 if( ! isset( $GLOBALS[$langver][$spage] ) )
312 $GLOBALS[$langver][$spage] = $text;
313 }
314 }
315 }
316 $this->mConverter = new fakeConverter($this);
317 }
318
319 /**
320 * Exports the default user options as defined in
321 * $wgDefaultUserOptionsEn, user preferences can override some of these
322 * depending on what's in (Local|Default)Settings.php and some defines.
323 *
324 * @return array
325 */
326 function getDefaultUserOptions() {
327 global $wgDefaultUserOptionsEn ;
328 return $wgDefaultUserOptionsEn ;
329 }
330
331 /**
332 * Exports $wgBookstoreListEn
333 * @return array
334 */
335 function getBookstoreList() {
336 global $wgBookstoreListEn ;
337 return $wgBookstoreListEn ;
338 }
339
340 /**
341 * @return array
342 */
343 function getNamespaces() {
344 global $wgNamespaceNamesEn;
345 return $wgNamespaceNamesEn;
346 }
347
348 /**
349 * A convenience function that returns the same thing as
350 * getNamespaces() except with the array values changed to ' '
351 * where it found '_', useful for producing output to be displayed
352 * e.g. in <select> forms.
353 *
354 * @return array
355 */
356 function getFormattedNamespaces() {
357 $ns = $this->getNamespaces();
358 foreach($ns as $k => $v) {
359 $ns[$k] = strtr($v, '_', ' ');
360 }
361 return $ns;
362 }
363
364 /**
365 * Get a namespace value by key
366 * <code>
367 * $mw_ns = $wgContLang->getNsText( NS_MEDIAWIKI );
368 * echo $mw_ns; // prints 'MediaWiki'
369 * </code>
370 *
371 * @param int $index the array key of the namespace to return
372 * @return mixed, string if the namespace value exists, otherwise false
373 */
374 function getNsText( $index ) {
375 $ns = $this->getNamespaces();
376 return isset( $ns[$index] ) ? $ns[$index] : false;
377 }
378
379 /**
380 * A convenience function that returns the same thing as
381 * getNsText() except with '_' changed to ' ', useful for
382 * producing output.
383 *
384 * @return array
385 */
386 function getFormattedNsText( $index ) {
387 $ns = $this->getNsText( $index );
388 return strtr($ns, '_', ' ');
389 }
390
391 /**
392 * Get a namespace key by value, case insensetive.
393 *
394 * @param string $text
395 * @return mixed An integer if $text is a valid value otherwise false
396 */
397 function getNsIndex( $text ) {
398 $ns = $this->getNamespaces();
399
400 foreach ( $ns as $i => $n ) {
401 if ( strcasecmp( $n, $text ) == 0)
402 return $i;
403 }
404 return false;
405 }
406
407 /**
408 * short names for language variants used for language conversion links.
409 *
410 * @param string $code
411 * @return string
412 */
413 function getVariantname( $code ) {
414 return wfMsg( "variantname-$code" );
415 }
416
417 function specialPage( $name ) {
418 return $this->getNsText(NS_SPECIAL) . ':' . $name;
419 }
420
421 function getQuickbarSettings() {
422 global $wgQuickbarSettingsEn;
423 return $wgQuickbarSettingsEn;
424 }
425
426 function getSkinNames() {
427 global $wgSkinNamesEn;
428 return $wgSkinNamesEn;
429 }
430
431 function getMathNames() {
432 global $wgMathNamesEn;
433 return $wgMathNamesEn;
434 }
435
436 function getDateFormats() {
437 global $wgDateFormatsEn;
438 return $wgDateFormatsEn;
439 }
440
441 function getUserToggles() {
442 global $wgUserTogglesEn;
443 return $wgUserTogglesEn;
444 }
445
446 function getUserToggle( $tog ) {
447 return wfMsg( "tog-$tog" );
448 }
449
450 function getLanguageNames() {
451 global $wgLanguageNamesEn;
452 return $wgLanguageNamesEn;
453 }
454
455 function getLanguageName( $code ) {
456 global $wgLanguageNamesEn;
457 if ( ! array_key_exists( $code, $wgLanguageNamesEn ) ) {
458 return '';
459 }
460 return $wgLanguageNamesEn[$code];
461 }
462
463 function getMonthName( $key ) {
464 global $wgMonthNamesEn, $wgContLang;
465 // see who called us and use the correct message function
466 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
467 return wfMsgForContent($wgMonthNamesEn[$key-1]);
468 else
469 return wfMsg($wgMonthNamesEn[$key-1]);
470 }
471
472 /* by default we just return base form */
473 function getMonthNameGen( $key ) {
474 return $this->getMonthName( $key );
475 }
476
477 function getMonthAbbreviation( $key ) {
478 global $wgMonthAbbreviationsEn, $wgContLang;
479 // see who called us and use the correct message function
480 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
481 return wfMsgForContent(@$wgMonthAbbreviationsEn[$key-1]);
482 else
483 return wfMsg(@$wgMonthAbbreviationsEn[$key-1]);
484 }
485
486 function getWeekdayName( $key ) {
487 global $wgWeekdayNamesEn, $wgContLang;
488 // see who called us and use the correct message function
489 if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
490 return wfMsgForContent($wgWeekdayNamesEn[$key-1]);
491 else
492 return wfMsg($wgWeekdayNamesEn[$key-1]);
493 }
494
495 /**
496 * Used by date() and time() to adjust the time output.
497 * @access public
498 * @param int $ts the time in date('YmdHis') format
499 * @param mixed $tz adjust the time by this amount (default false)
500 * @return int
501
502 */
503 function userAdjust( $ts, $tz = false ) {
504 global $wgUser, $wgLocalTZoffset;
505
506 if (!$tz) {
507 $tz = $wgUser->getOption( 'timecorrection' );
508 }
509
510 if ( $tz === '' ) {
511 $hrDiff = isset( $wgLocalTZoffset ) ? $wgLocalTZoffset : 0;
512 $minDiff = 0;
513 } elseif ( strpos( $tz, ':' ) !== false ) {
514 $tzArray = explode( ':', $tz );
515 $hrDiff = intval($tzArray[0]);
516 $minDiff = intval($hrDiff < 0 ? -$tzArray[1] : $tzArray[1]);
517 } else {
518 $hrDiff = intval( $tz );
519 }
520 if ( 0 == $hrDiff && 0 == $minDiff ) { return $ts; }
521
522 $t = mktime( (
523 (int)substr( $ts, 8, 2) ) + $hrDiff, # Hours
524 (int)substr( $ts, 10, 2 ) + $minDiff, # Minutes
525 (int)substr( $ts, 12, 2 ), # Seconds
526 (int)substr( $ts, 4, 2 ), # Month
527 (int)substr( $ts, 6, 2 ), # Day
528 (int)substr( $ts, 0, 4 ) ); #Year
529 return date( 'YmdHis', $t );
530 }
531
532 /**
533 * This is meant to be used by time(), date(), and timeanddate() to get
534 * the date preference they're supposed to use, it should be used in
535 * all children.
536 *
537 *<code>
538 * function timeanddate([...], $format = true) {
539 * $datePreference = $this->dateFormat($format);
540 * [...]
541 *</code>
542 *
543 * @param mixed $usePrefs: if true, the user's preference is used
544 * if false, the site/language default is used
545 * if int/string, assumed to be a format.
546 * @return string
547 */
548 function dateFormat( $usePrefs = true ) {
549 global $wgUser;
550
551 if( is_bool( $usePrefs ) ) {
552 if( $usePrefs ) {
553 $datePreference = $wgUser->getOption( 'date' );
554 } else {
555 $options = $this->getDefaultUserOptions();
556 $datePreference = (string)$options['date'];
557 }
558 } else {
559 $datePreference = (string)$usePrefs;
560 }
561
562 // return int
563 if( $datePreference == '' ) {
564 return MW_DATE_DEFAULT;
565 }
566
567 return $datePreference;
568 }
569
570 /**
571 * @access public
572 * @param mixed $ts the time format which needs to be turned into a
573 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
574 * @param bool $adj whether to adjust the time output according to the
575 * user configured offset ($timecorrection)
576 * @param mixed $format true to use user's date format preference
577 * @param string $timecorrection the time offset as returned by
578 * validateTimeZone() in Special:Preferences
579 * @return string
580 */
581 function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
582 global $wgUser, $wgAmericanDates;
583
584 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
585
586 $datePreference = $this->dateFormat( $format );
587 if( $datePreference == MW_DATE_DEFAULT ) {
588 $datePreference = $wgAmericanDates ? MW_DATE_MDY : MW_DATE_DMY;
589 }
590
591 $month = $this->formatMonth( substr( $ts, 4, 2 ), $datePreference );
592 $day = $this->formatDay( substr( $ts, 6, 2 ), $datePreference );
593 $year = $this->formatNum( substr( $ts, 0, 4 ), true );
594
595 switch( $datePreference ) {
596 case MW_DATE_DMY: return "$day $month $year";
597 case MW_DATE_YMD: return "$year $month $day";
598 case MW_DATE_ISO: return substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .substr($ts, 6, 2);
599 default: return "$month $day, $year";
600 }
601 }
602
603 /**
604 * @access public
605 * @param mixed $ts the time format which needs to be turned into a
606 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
607 * @param bool $adj whether to adjust the time output according to the
608 * user configured offset ($timecorrection)
609 * @param mixed $format true to use user's date format preference
610 * @param string $timecorrection the time offset as returned by
611 * validateTimeZone() in Special:Preferences
612 * @return string
613 */
614 function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
615 global $wgUser;
616
617 if ( $adj ) { $ts = $this->userAdjust( $ts, $timecorrection ); }
618 $datePreference = $this->dateFormat( $format );
619
620 $sep = ($datePreference == MW_DATE_ISO)
621 ? ':'
622 : $this->timeSeparator( $format );
623
624 $t = substr( $ts, 8, 2 ) . $sep . substr( $ts, 10, 2 );
625
626 if ( $datePreference == MW_DATE_ISO ) {
627 $t .= $sep . substr( $ts, 12, 2 );
628 }
629 return $t;
630 }
631
632 /**
633 * Default separator character between hours, minutes, and seconds.
634 * Will be used by Language::time() for non-ISO formats.
635 * (ISO will always use a colon.)
636 * @return string
637 */
638 function timeSeparator( $format ) {
639 return ':';
640 }
641
642 /**
643 * String to insert between the time and the date in a combined
644 * string. Should include any relevant whitespace.
645 * @return string
646 */
647 function timeDateSeparator( $format ) {
648 return ', ';
649 }
650
651 /**
652 * Return true if the time should display before the date.
653 * @return bool
654 * @access private
655 */
656 function timeBeforeDate() {
657 return true;
658 }
659
660 function formatMonth( $month, $format ) {
661 return $this->getMonthName( $month );
662 }
663
664 function formatDay( $day, $format ) {
665 return $this->formatNum( 0 + $day );
666 }
667
668 /**
669 * @access public
670 * @param mixed $ts the time format which needs to be turned into a
671 * date('YmdHis') format with wfTimestamp(TS_MW,$ts)
672 * @param bool $adj whether to adjust the time output according to the
673 * user configured offset ($timecorrection)
674
675 * @param mixed $format what format to return, if it's false output the
676 * default one (default true)
677 * @param string $timecorrection the time offset as returned by
678 * validateTimeZone() in Special:Preferences
679 * @return string
680 */
681 function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
682 global $wgUser;
683
684 $datePreference = $this->dateFormat($format);
685 switch ( $datePreference ) {
686 case MW_DATE_ISO: return $this->date( $ts, $adj, $format, $timecorrection ) . ' ' .
687 $this->time( $ts, $adj, $format, $timecorrection );
688 default:
689 $time = $this->time( $ts, $adj, $format, $timecorrection );
690 $sep = $this->timeDateSeparator( $datePreference );
691 $date = $this->date( $ts, $adj, $format, $timecorrection );
692 return $this->timeBeforeDate( $datePreference )
693 ? $time . $sep . $date
694 : $date . $sep . $time;
695 }
696 }
697
698 function getMessage( $key ) {
699 global $wgAllMessagesEn;
700 return @$wgAllMessagesEn[$key];
701 }
702
703 function getAllMessages() {
704 global $wgAllMessagesEn;
705 return $wgAllMessagesEn;
706 }
707
708 function iconv( $in, $out, $string ) {
709 # For most languages, this is a wrapper for iconv
710 return iconv( $in, $out, $string );
711 }
712
713 function ucfirst( $string ) {
714 # For most languages, this is a wrapper for ucfirst()
715 return ucfirst( $string );
716 }
717
718 function uc( $str ) {
719 return strtoupper( $str );
720 }
721
722 function lcfirst( $s ) {
723 return strtolower( $s{0} ). substr( $s, 1 );
724 }
725
726 function lc( $str ) {
727 return strtolower( $str );
728 }
729
730 function checkTitleEncoding( $s ) {
731 global $wgInputEncoding;
732
733 # Check for UTF-8 URLs; Internet Explorer produces these if you
734 # type non-ASCII chars in the URL bar or follow unescaped links.
735 $ishigh = preg_match( '/[\x80-\xff]/', $s);
736 $isutf = ($ishigh ? preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
737 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true );
738
739 if( ($wgInputEncoding != 'utf-8') and $ishigh and $isutf )
740 return @iconv( 'UTF-8', $wgInputEncoding, $s );
741
742 if( ($wgInputEncoding == 'utf-8') and $ishigh and !$isutf )
743 return utf8_encode( $s );
744
745 # Other languages can safely leave this function, or replace
746 # it with one to detect and convert another legacy encoding.
747 return $s;
748 }
749
750 /**
751 * Some languages have special punctuation to strip out
752 * or characters which need to be converted for MySQL's
753 * indexing to grok it correctly. Make such changes here.
754 *
755 * @param string $in
756 * @return string
757 */
758 function stripForSearch( $in ) {
759 return strtolower( $in );
760 }
761
762 function convertForSearchResult( $termsArray ) {
763 # some languages, e.g. Chinese, need to do a conversion
764 # in order for search results to be displayed correctly
765 return $termsArray;
766 }
767
768 /**
769 * Get the first character of a string. In ASCII, return
770 * first byte of the string. UTF8 and others have to
771 * overload this.
772 *
773 * @param string $s
774 * @return string
775 */
776 function firstChar( $s ) {
777 return $s[0];
778 }
779
780 function initEncoding() {
781 # Some languages may have an alternate char encoding option
782 # (Esperanto X-coding, Japanese furigana conversion, etc)
783 # If this language is used as the primary content language,
784 # an override to the defaults can be set here on startup.
785 #global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
786 }
787
788 function setAltEncoding() {
789 # Some languages may have an alternate char encoding option
790 # (Esperanto X-coding, Japanese furigana conversion, etc)
791 # If 'altencoding' is checked in user prefs, this gives a
792 # chance to swap out the default encoding settings.
793 #global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
794 }
795
796 function recodeForEdit( $s ) {
797 # For some languages we'll want to explicitly specify
798 # which characters make it into the edit box raw
799 # or are converted in some way or another.
800 # Note that if wgOutputEncoding is different from
801 # wgInputEncoding, this text will be further converted
802 # to wgOutputEncoding.
803 global $wgInputEncoding, $wgEditEncoding;
804 if( $wgEditEncoding == '' or
805 $wgEditEncoding == $wgInputEncoding ) {
806 return $s;
807 } else {
808 return $this->iconv( $wgInputEncoding, $wgEditEncoding, $s );
809 }
810 }
811
812 function recodeInput( $s ) {
813 # Take the previous into account.
814 global $wgInputEncoding, $wgOutputEncoding, $wgEditEncoding;
815 if($wgEditEncoding != "") {
816 $enc = $wgEditEncoding;
817 } else {
818 $enc = $wgOutputEncoding;
819 }
820 if( $enc == $wgInputEncoding ) {
821 return $s;
822 } else {
823 return $this->iconv( $enc, $wgInputEncoding, $s );
824 }
825 }
826
827 /**
828 * For right-to-left language support
829 *
830 * @return bool
831 */
832 function isRTL() { return false; }
833
834 /**
835 * To allow "foo[[bar]]" to extend the link over the whole word "foobar"
836 *
837 * @return bool
838 */
839 function linkPrefixExtension() { return false; }
840
841
842 function &getMagicWords() {
843 global $wgMagicWordsEn;
844 return $wgMagicWordsEn;
845 }
846
847 # Fill a MagicWord object with data from here
848 function getMagic( &$mw ) {
849 $raw = $this->getMagicWords();
850
851 wfRunHooks( 'LanguageGetMagic', array( &$raw ) );
852
853 if( !isset( $raw[$mw->mId] ) ) {
854 # Fall back to English if local list is incomplete
855 $raw =& Language::getMagicWords();
856 }
857 $rawEntry = $raw[$mw->mId];
858 $mw->mCaseSensitive = $rawEntry[0];
859 $mw->mSynonyms = array_slice( $rawEntry, 1 );
860 }
861
862 /**
863 * Italic is unsuitable for some languages
864 *
865 * @access public
866 *
867 * @param string $text The text to be emphasized.
868 * @return string
869 */
870 function emphasize( $text ) {
871 return "<em>$text</em>";
872 }
873
874 /**
875 * This function enables formatting of numbers, it should only come
876 * into effect when the $wgTranslateNumerals variable is TRUE.
877 *
878 * Normally we output all numbers in plain en_US style, that is
879 * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
880 * point twohundredthirtyfive. However this is not sutable for all
881 * languages, some such as Pakaran want ੨੯੩,੨੯੫.੨੩੫ and others such as
882 * Icelandic just want to use commas instead of dots, and dots instead
883 * of commas like "293.291,235".
884 *
885 * An example of this function being called:
886 * <code>
887 * wfMsg( 'message', $wgLang->formatNum( $num ) )
888 * </code>
889 *
890 * See LanguageGu.php for the Gujarati implementation and
891 * LanguageIs.php for the , => . and . => , implementation.
892 *
893 * @todo check if it's viable to use localeconv() for the decimal
894 * seperator thing.
895 * @access public
896 * @param mixed $number the string to be formatted, should be an integer or
897 * a floating point number.
898 * @param bool $year are we being passed a year? (turns off commafication)
899 * @return mixed whatever we're fed if it's a year, a string otherwise.
900 */
901 function formatNum( $number, $year = false ) {
902 return $year ? $number : $this->commafy($number);
903 }
904
905 /**
906 * Adds commas to a given number
907 *
908 * @param mixed $_
909 * @return string
910 */
911 function commafy($_) {
912 return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_)));
913 }
914
915 /**
916 * For the credit list in includes/Credits.php (action=credits)
917 *
918 * @param array $l
919 * @return string
920 */
921 function listToText( $l ) {
922 $s = '';
923 $m = count($l) - 1;
924 for ($i = $m; $i >= 0; $i--) {
925 if ($i == $m) {
926 $s = $l[$i];
927 } else if ($i == $m - 1) {
928 $s = $l[$i] . ' ' . wfMsg('and') . ' ' . $s;
929 } else {
930 $s = $l[$i] . ', ' . $s;
931 }
932 }
933 return $s;
934 }
935
936 # Crop a string from the beginning or end to a certain number of bytes.
937 # (Bytes are used because our storage has limited byte lengths for some
938 # columns in the database.) Multibyte charsets will need to make sure that
939 # only whole characters are included!
940 #
941 # $length does not include the optional ellipsis.
942 # If $length is negative, snip from the beginning
943 function truncate( $string, $length, $ellipsis = '' ) {
944 if( $length == 0 ) {
945 return $ellipsis;
946 }
947 if ( strlen( $string ) <= abs( $length ) ) {
948 return $string;
949 }
950 if( $length > 0 ) {
951 $string = substr( $string, 0, $length );
952 return $string . $ellipsis;
953 } else {
954 $string = substr( $string, $length );
955 return $ellipsis . $string;
956 }
957 }
958
959 /**
960 * Grammatical transformations, needed for inflected languages
961 * Invoked by putting {{grammar:case|word}} in a message
962 *
963 * @param string $word
964 * @param string $case
965 * @return string
966 */
967 function convertGrammar( $word, $case ) {
968 return $word;
969 }
970
971 /**
972 * Plural form transformations, needed for some languages.
973 * For example, where are 3 form of plural in Russian and Polish,
974 * depending on "count mod 10". See [[w:Plural]]
975 * For English it is pretty simple.
976 *
977 * Invoked by putting {{plural:count|wordform1|wordform2}}
978 * or {{plural:count|wordform1|wordform2|wordform3}}
979 *
980 * Example: {{plural:{{NUMBEROFARTICLES}}|article|articles}}
981 *
982 * @param integer $count
983 * @param string $wordform1
984 * @param string $wordform2
985 * @param string $wordform3 (optional)
986 * @return string
987 */
988 function convertPlural( $count, $wordform1, $wordform2, $wordform3) {
989 return $count == '1' ? $wordform1 : $wordform2;
990 }
991
992 /**
993 * For translaing of expiry times
994 * @param string The validated block time in English
995 * @return Somehow translated block time
996 * @see LanguageFi.php for example implementation
997 */
998 function translateBlockExpiry( $str ) {
999
1000 $scBlockExpiryOptions = wfMsg( 'ipboptions' );
1001
1002 if ( $scBlockExpiryOptions == '-') {
1003 return $str;
1004 }
1005
1006 foreach (explode(',', $scBlockExpiryOptions) as $option) {
1007 if ( strpos($option, ":") === false )
1008 continue;
1009 list($show, $value) = explode(":", $option);
1010 if ( strcmp ( $str, $value) == 0 )
1011 return '<span title="' . htmlspecialchars($str). '">' .
1012 htmlspecialchars( trim( $show ) ) . '</span>';
1013 }
1014
1015 return $str;
1016 }
1017
1018 /**
1019 * languages like Chinese need to be segmented in order for the diff
1020 * to be of any use
1021 *
1022 * @param string $text
1023 * @return string
1024 */
1025 function segmentForDiff( $text ) {
1026 return $text;
1027 }
1028
1029 /**
1030 * and unsegment to show the result
1031 *
1032 * @param string $text
1033 * @return string
1034 */
1035 function unsegmentForDiff( $text ) {
1036 return $text;
1037 }
1038
1039 # convert text to different variants of a language.
1040 function convert( $text, $isTitle = false) {
1041 return $this->mConverter->convert($text, $isTitle);
1042 }
1043
1044 # Convert text from within Parser
1045 function parserConvert( $text, &$parser ) {
1046 return $this->mConverter->parserConvert( $text, $parser );
1047 }
1048
1049 /**
1050 * Perform output conversion on a string, and encode for safe HTML output.
1051 * @param string $text
1052 * @param bool $isTitle -- wtf?
1053 * @return string
1054 * @todo this should get integrated somewhere sane
1055 */
1056 function convertHtml( $text, $isTitle = false ) {
1057 return htmlspecialchars( $this->convert( $text, $isTitle ) );
1058 }
1059
1060 function convertCategoryKey( $key ) {
1061 return $this->mConverter->convertCategoryKey( $key );
1062 }
1063
1064 /**
1065 * get the list of variants supported by this langauge
1066 * see sample implementation in LanguageZh.php
1067 *
1068 * @return array an array of language codes
1069 */
1070 function getVariants() {
1071 return $this->mConverter->getVariants();
1072 }
1073
1074
1075 function getPreferredVariant() {
1076 return $this->mConverter->getPreferredVariant();
1077 }
1078
1079 /**
1080 * if a language supports multiple variants, it is
1081 * possible that non-existing link in one variant
1082 * actually exists in another variant. this function
1083 * tries to find it. See e.g. LanguageZh.php
1084 *
1085 * @param string $link the name of the link
1086 * @param mixed $nt the title object of the link
1087 * @return null the input parameters may be modified upon return
1088 */
1089 function findVariantLink( &$link, &$nt ) {
1090 $this->mConverter->findVariantLink($link, $nt);
1091 }
1092
1093 /**
1094 * returns language specific options used by User::getPageRenderHash()
1095 * for example, the preferred language variant
1096 *
1097 * @return string
1098 * @access public
1099 */
1100 function getExtraHashOptions() {
1101 return $this->mConverter->getExtraHashOptions();
1102 }
1103
1104 /**
1105 * for languages that support multiple variants, the title of an
1106 * article may be displayed differently in different variants. this
1107 * function returns the apporiate title defined in the body of the article.
1108 *
1109 * @return string
1110 */
1111 function getParsedTitle() {
1112 return $this->mConverter->getParsedTitle();
1113 }
1114
1115 /**
1116 * Enclose a string with the "no conversion" tag. This is used by
1117 * various functions in the Parser
1118 *
1119 * @param string $text text to be tagged for no conversion
1120 * @return string the tagged text
1121 */
1122 function markNoConversion( $text ) {
1123 return $this->mConverter->markNoConversion( $text );
1124 }
1125
1126 /**
1127 * A regular expression to match legal word-trailing characters
1128 * which should be merged onto a link of the form [[foo]]bar.
1129 *
1130 * @return string
1131 * @access public
1132 */
1133 function linkTrail() {
1134 return $this->getMessage( 'linktrail' );
1135 }
1136
1137 function getLangObj() {
1138 return $this;
1139 }
1140
1141 /**
1142 * Get the RFC 3066 code for this language object
1143 */
1144 function getCode() {
1145 return str_replace( '_', '-', strtolower( substr( get_class( $this ), 8 ) ) );
1146 }
1147
1148
1149 }
1150
1151 # FIXME: Merge all UTF-8 support code into Language base class.
1152 # We no longer support Latin-1 charset.
1153 require_once( 'LanguageUtf8.php' );
1154
1155 # This should fail gracefully if there's not a localization available
1156 wfSuppressWarnings();
1157 // Preload base classes to work around APC/PHP5 bug
1158 include_once( 'Language' . str_replace( '-', '_', ucfirst( $wgLanguageCode ) ) . '.deps.php' );
1159 include_once( 'Language' . str_replace( '-', '_', ucfirst( $wgLanguageCode ) ) . '.php' );
1160 wfRestoreWarnings();
1161
1162 }
1163 ?>