r97713 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97712‎ | r97713 | r97714 >
Date:11:14, 21 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Followup r93985 - split the hook into two: one for page translation and one for the rest
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -59,13 +59,13 @@
6060 }
6161
6262 /**
63 - * Set the right page content language for translated pages ("Page/xx")
64 - * and namespaces used for translating messages (similar to MediaWiki namespace pages)
 63+ * Set the right page content language for translated pages ("Page/xx").
 64+ * Hook: PageContentLanguage
6565 */
6666 public static function onPageContentLanguage( $title, &$pageLang ) {
6767 global $wgTranslateMessageNamespaces;
6868 // For translation pages, parse plural, grammar etc with correct language, and set the right direction
69 - if ( TranslatablePage::isTranslationPage( $title ) || in_array( $title->getNamespace(), $wgTranslateMessageNamespaces ) ) {
 69+ if ( TranslatablePage::isTranslationPage( $title ) ) {
7070 list( , $code ) = TranslateUtils::figureMessage( $title->getText() );
7171 $pageLang = $code;
7272 }
Index: trunk/extensions/Translate/Translate.php
@@ -54,6 +54,7 @@
5555 $wgHooks['UnitTestsList'][] = 'TranslateHooks::setupUnitTests';
5656 $wgHooks['LoadExtensionSchemaUpdates'][] = 'TranslateHooks::schemaUpdates';
5757 $wgHooks['ParserTestTables'][] = 'PageTranslationHooks::parserTestTables';
 58+$wgHooks['PageContentLanguage'][] = 'TranslateHooks::onPageContentLanguage';
5859
5960 // Register special pages into MediaWiki
6061 $wgSpecialPages['Translate'] = 'SpecialTranslate';
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -175,4 +175,19 @@
176176 return true;
177177 }
178178
 179+
 180+ /**
 181+ * Set the right page content language for message group translations ("Page/xx").
 182+ * Hook: PageContentLanguage
 183+ */
 184+ public static function onPageContentLanguage( $title, &$pageLang ) {
 185+ global $wgTranslateMessageNamespaces;
 186+ // For translation pages, parse plural, grammar etc with correct language, and set the right direction
 187+ if ( in_array( $title->getNamespace(), $wgTranslateMessageNamespaces ) ) {
 188+ list( , $code ) = TranslateUtils::figureMessage( $title->getText() );
 189+ $pageLang = $code;
 190+ }
 191+ return true;
 192+ }
 193+
179194 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93985Use page content language for the WikimediaIncubator and Translate extension....robin16:57, 5 August 2011

Status & tagging log