Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php |
— | — | @@ -419,11 +419,11 @@ |
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
423 | | - public static function time( $parser, $format = '', $date = '', $local = false ) { |
424 | | - global $wgContLang, $wgLocaltimezone; |
| 423 | + public static function time( $parser, $format = '', $date = '', $language = '', $local = false ) { |
| 424 | + global $wgLang, $wgContLang, $wgLocaltimezone; |
425 | 425 | self::registerClearHook(); |
426 | | - if ( isset( self::$mTimeCache[$format][$date][$local] ) ) { |
427 | | - return self::$mTimeCache[$format][$date][$local]; |
| 426 | + if ( isset( self::$mTimeCache[$format][$date][$language][$local] ) ) { |
| 427 | + return self::$mTimeCache[$format][$date][$language][$local]; |
428 | 428 | } |
429 | 429 | |
430 | 430 | # compute the timestamp string $ts |
— | — | @@ -504,15 +504,22 @@ |
505 | 505 | if ( self::$mTimeChars > self::$mMaxTimeChars ) { |
506 | 506 | return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>'; |
507 | 507 | } else { |
508 | | - $result = $wgContLang->sprintfDate( $format, $ts ); |
| 508 | + if ( $language == 'user' ) { // use user's interface language |
| 509 | + $result = $wgLang->sprintfDate( $format, $ts ); |
| 510 | + } elseif ( $language !== '' ) { // use whatever language is passed as a parameter |
| 511 | + $langObject = Language::factory( $language ); |
| 512 | + $result = $langObject->sprintfDate( $format, $ts ); |
| 513 | + } else { // use wiki's content language |
| 514 | + $result = $wgContLang->sprintfDate( $format, $ts ); |
| 515 | + } |
509 | 516 | } |
510 | 517 | } |
511 | | - self::$mTimeCache[$format][$date][$local] = $result; |
| 518 | + self::$mTimeCache[$format][$date][$language][$local] = $result; |
512 | 519 | return $result; |
513 | 520 | } |
514 | 521 | |
515 | | - public static function localTime( $parser, $format = '', $date = '' ) { |
516 | | - return self::time( $parser, $format, $date, true ); |
| 522 | + public static function localTime( $parser, $format = '', $date = '', $language = '' ) { |
| 523 | + return self::time( $parser, $format, $date, $language, true ); |
517 | 524 | } |
518 | 525 | |
519 | 526 | /** |