r87305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87304‎ | r87305 | r87306 >
Date:22:21, 2 May 2011
Author:kaldari
Status:resolved (Comments)
Tags:
Comment:
fix issues from r86927, user language and years over 9999
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions.i18n.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -504,13 +504,18 @@
505505 if ( self::$mTimeChars > self::$mMaxTimeChars ) {
506506 return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>';
507507 } else {
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 );
 508+ if ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
 509+ if ( $language == 'user' ) { // use user's interface language
 510+ $parser->getOptions()->getUserLang();
 511+ $result = $wgLang->sprintfDate( $format, $ts );
 512+ } elseif ( $language !== '' ) { // use whatever language is passed as a parameter
 513+ $langObject = Language::factory( $language );
 514+ $result = $langObject->sprintfDate( $format, $ts );
 515+ } else { // use wiki's content language
 516+ $result = $wgContLang->sprintfDate( $format, $ts );
 517+ }
 518+ } else {
 519+ return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_big' ) . '</strong>';
515520 }
516521 }
517522 }
Index: trunk/extensions/ParserFunctions/ParserFunctions.i18n.php
@@ -12,6 +12,7 @@
1313 'pfunc_desc' => 'Enhance parser with logical functions',
1414 'pfunc_time_error' => 'Error: invalid time',
1515 'pfunc_time_too_long' => 'Error: too many #time calls',
 16+ 'pfunc_time_too_big' => 'Error: #time only supports years up to 9999',
1617 'pfunc_rel2abs_invalid_depth' => 'Error: Invalid depth in path: "$1" (tried to access a node above the root node)',
1718 'pfunc_expr_stack_exhausted' => 'Expression error: Stack exhausted',
1819 'pfunc_expr_unexpected_number' => 'Expression error: Unexpected number',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86927adding language support to #time parser function, per bug 28655kaldari00:26, 26 April 2011

Comments

#Comment by Bawolff (talk | contribs)   04:21, 13 May 2011

Perhaps should use the result $parser->getOptions()->getUserLang(); to get the language. I think in certain where circumstances it might not be $wgLang. The Message classes seem to be able to set it explicitly in some circumstances (Like if you ask for a message in a specific language). (The installer seems to as well, but that specific method does not appear to be called).

#Comment by Kaldari (talk | contribs)   09:00, 14 May 2011

I reverted that part in r87308. Plantonides suggested the magic language switching might be problematic, so we'll just let people use {{int:lang}} as the language parameter instead if they need that functionality.

Status & tagging log