r80437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80436‎ | r80437 | r80438 >
Date:06:41, 17 January 2011
Author:roberthl
Status:deferred
Tags:
Comment:
Translate: Use the new ArticlePrepareTextForEdit hook to disable pre-save transformation on all message pages except for the message documentation language.
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -473,4 +473,13 @@
474474 }
475475 return true;
476476 }
 477+
 478+ public static function disablePreSaveTransform( $article, $popts ) {
 479+ global $wgTranslateMessageNamespaces, $wgTranslateDocumentationLanguageCode;
 480+ if( in_array( $article->getTitle()->getNamespace(), $wgTranslateMessageNamespaces )
 481+ && $article->getTitle()->getSubpageText() !== $wgTranslateDocumentationLanguageCode ) {
 482+ $popts->setPreSaveTransform( false );
 483+ }
 484+ return true;
 485+ }
477486 }
Index: trunk/extensions/Translate/Translate.php
@@ -92,6 +92,7 @@
9393 $wgHooks['ArticleAfterFetchContent'][] = 'TranslateEditAddons::customDisplay';
9494 $wgHooks['ParserBeforeStrip'][] = 'TranslateEditAddons::injectTranslationDisplayJs';
9595 $wgHooks['LanguageGetTranslatedLanguageNames'][] = 'TranslateEditAddons::translateMessageDocumentationLanguage';
 96+$wgHooks['ArticlePrepareTextForEdit'][] = 'TranslateEditAddons::disablePreSaveTransform';
9697
9798 // Custom preferences
9899 $wgDefaultUserOptions['translate'] = 0;

Status & tagging log