r76116 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76115‎ | r76116 | r76117 >
Date:17:41, 5 November 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Work-in-progress custom page display of translations
Modified paths:
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -409,8 +409,23 @@
410410 }
411411
412412 public static function customDisplay( $article, &$content ) {
413 - if ( self::isMessageNamespace( $article->getTitle() ) ) {
414 - $content = "<pre><nowiki>$content</nowiki></pre>";
 413+ global $wgRequest, $wgTitle;
 414+ if (
 415+ $wgRequest->getVal( 'action' ) !== 'edit' &&
 416+ $article->getTitle()->equals( $wgTitle ) &&
 417+ self::isMessageNamespace( $article->getTitle() ) )
 418+ {
 419+ list( $key, $code, $group ) = self::getKeyCodeGroup( $article->getTitle() );
 420+ $def = $group->getMessage( $key, 'en' );
 421+ $content = TranslateUtils::convertWhiteSpaceToHTML( $content );
 422+ $deftext = wfMsgNoTrans( 'translate-edit-show-def' );
 423+ $trans = wfMsgNoTrans( 'translate-edit-show-trans' );
 424+ $content = <<<HTML
 425+<table class=wikitable>
 426+ <tr><th>$deftext</th><th>$trans</th></tr>
 427+ <tr><td><nowiki>$def</nowiki></td><td><nowiki>$content</nowiki></td></tr>
 428+</table>
 429+HTML;
415430 }
416431 return true;
417432 }
Index: trunk/extensions/Translate/Translate.php
@@ -90,6 +90,7 @@
9191 $wgHooks['EditPageBeforeEditButtons'][] = 'TranslateEditAddons::buttonHack';
9292 $wgHooks['EditPage::showEditForm:fields'][] = 'TranslateEditAddons::keepFields';
9393 $wgHooks['SkinTemplateTabs'][] = 'TranslateEditAddons::tabs';
 94+$wgHooks['ArticleAfterFetchContent'][] = 'TranslateEditAddons::customDisplay';
9495
9596 // Custom preferences
9697 $wgDefaultUserOptions['translate'] = 0;
@@ -670,4 +671,4 @@
671672 $wgNamespacesToBeSearchedDefault[$id] = true;
672673 }
673674
674 -/** @defgroup TranslateSpecialPage Special pages of Translate extension */
 675+/** @defgroup TranslateSpecialPage Special pages of Translate extension */
\ No newline at end of file
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -85,8 +85,11 @@
8686
8787 'translate-edit-tab-prev' => '<<<',
8888 'translate-edit-tab-next' => '>>>',
89 - 'translate-edit-tab-list' => 'Message list',
 89+ 'translate-edit-tab-list' => 'Message list',
9090
 91+ 'translate-edit-show-def' => 'Message definition',
 92+ 'translate-edit-show-trans' => 'Translation',
 93+
9194 'translate-magic-pagename' => 'Extended MediaWiki translation',
9295 'translate-magic-help' => 'You can translate special pages aliases, magic words and namespace names.
9396

Status & tagging log