r56366 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56365‎ | r56366 | r56367 >
Date:16:14, 15 September 2009
Author:raymond
Status:ok
Tags:
Comment:
Bug 20652: Make hardcoded error message localizable.
Modified paths:
  • /trunk/extensions/timeline/Timeline.i18n.php (modified) (history)
  • /trunk/extensions/timeline/Timeline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/timeline/Timeline.i18n.php
@@ -11,6 +11,7 @@
1212 /** English */
1313 $messages['en'] = array(
1414 'timeline-desc' => 'Adds <tt>&lt;timeline&gt;</tt> tag to create timelines',
 15+ 'timeline-invalidmap' => 'Invalid image map generated by EasyTimeline',
1516 );
1617
1718 /** Message documentation (Message documentation)
Index: trunk/extensions/timeline/Timeline.php
@@ -130,18 +130,19 @@
131131 */
132132 function easyTimelineFixMap( $html ) {
133133 global $wgUrlProtocols;
134 - $error = '<strong class="error">Invalid image map generated by EasyTimeline</strong>';
135134 $doc = new DOMDocument( '1.0', 'UTF-8' );
136135 wfSuppressWarnings();
137136 $status = $doc->loadXML( $html );
138137 wfRestoreWarnings();
139138 if ( !$status ) {
140 - return $error;
 139+ wfLoadExtensionMessages( 'Timeline' ); // Load messages only if error occurs
 140+ return '<strong class="error">' . wfMsg( 'timeline-invalidmap' ) . '</strong>';
141141 }
142142
143143 $map = $doc->firstChild;
144144 if ( strtolower( $map->nodeName ) !== 'map' ) {
145 - return $error;
 145+ wfLoadExtensionMessages( 'Timeline' ); // Load messages only if error occurs
 146+ return '<strong class="error">' . wfMsg( 'timeline-invalidmap' ) . '</strong>';
146147 }
147148 $name = $map->attributes->getNamedItem( 'name' )->value;
148149 $html = Xml::openElement( 'map', array( 'name' => $name ) );

Status & tagging log