r89977 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89976‎ | r89977 | r89978 >
Date:16:26, 13 June 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
* followup r89895: make magic words localisation look common
* fix (extension credits not shown if Lingo is only extension (ha, as if))
* new setting $wgexLingoDisplayOnce
Modified paths:
  • /trunk/extensions/Lingo/Lingo.i18n.magic.php (added) (history)
  • /trunk/extensions/Lingo/Lingo.i18n.php (modified) (history)
  • /trunk/extensions/Lingo/Lingo.php (modified) (history)
  • /trunk/extensions/Lingo/LingoElement.php (modified) (history)
  • /trunk/extensions/Lingo/LingoHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Lingo/LingoHooks.php
@@ -18,11 +18,6 @@
1919 */
2020 class LingoHooks {
2121
22 - static function setMagicWords( &$magicWords, $langCode ) {
23 - $magicWords['noglossary'] = array( 0, '__NOGLOSSARY__', '__' . wfMsgGetKey( 'lingo-noglossary', true, $langCode ) . '__' );
24 - return true;
25 - }
26 -
2722 static function parse( &$parser, &$text ) {
2823
2924 if ( !isset( $parser->mDoubleUnderscores['noglossary'] ) ) {
@@ -33,9 +28,9 @@
3429 }
3530
3631 /**
37 - * Deferred setting of extension credits
 32+ * Deferred setting of description in extension credits
3833 *
39 - * Setting of extension credits has to be deferred to the
 34+ * Setting of description in extension credits has to be deferred to the
4035 * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage (which
4136 * might be set only after inclusion of the extension in LocalSettings) and
4237 * function wfMsg not available before.
@@ -45,14 +40,8 @@
4641 static function setCredits() {
4742
4843 global $wgExtensionCredits, $wgexLingoPage;
49 - $wgExtensionCredits['parserhook'][] = array(
50 - 'path' => __FILE__,
51 - 'name' => 'Lingo',
52 - 'author' => array( 'Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ),
53 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo',
54 - 'descriptionmsg' => array( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) ),
55 - 'version' => LINGO_VERSION,
56 - );
 44+ $wgExtensionCredits['parserhook']['lingo']['description'] =
 45+ wfMsg( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) );
5746
5847 return true;
5948 }
Index: trunk/extensions/Lingo/LingoElement.php
@@ -27,6 +27,8 @@
2828 private $mFullDefinition = null;
2929 private $mDefinitions = array();
3030 private $mTerm = null;
 31+ private $mHasBeenDisplayed = false;
 32+
3133 static private $mLinkTemplate = null;
3234
3335 public function __construct( &$term, &$definition = null ) {
@@ -43,6 +45,14 @@
4446 }
4547
4648 public function getFullDefinition( DOMDocument &$doc ) {
 49+
 50+ global $wgexLingoDisplayOnce;
 51+
 52+ // return textnode if
 53+ if ( $wgexLingoDisplayOnce && $this->mHasBeenDisplayed ) {
 54+ return $doc->createTextNode($this->mTerm);
 55+ }
 56+
4757 // only create if not yet created
4858 if ( $this->mFullDefinition == null || $this->mFullDefinition->ownerDocument !== $doc ) {
4959
@@ -84,6 +94,7 @@
8595 $spanDefinitionOuter->appendChild( $spanDefinitionInner );
8696
8797 $this->mFullDefinition = $span;
 98+ $this->mHasBeenDisplayed = true;
8899 }
89100
90101 return $this->mFullDefinition->cloneNode( true );
Index: trunk/extensions/Lingo/Lingo.i18n.magic.php
@@ -0,0 +1,15 @@
 2+<?php
 3+
 4+$magicWords = array();
 5+
 6+/** English (English) */
 7+$magicWords['en'] = array(
 8+ 'noglossary' => array( 0, '__NOGLOSSARY__' ),
 9+);
 10+
 11+/** German (Deutsch) */
 12+$magicWords['en'] = array(
 13+ 'noglossary' => array( 0, '__KEIN_GLOSSAR__', '__NOGLOSSARY__' ),
 14+);
 15+
 16+
Property changes on: trunk/extensions/Lingo/Lingo.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
117 + native
Index: trunk/extensions/Lingo/Lingo.i18n.php
@@ -13,14 +13,12 @@
1414 'lingo-terminologypagename' => 'Terminology',
1515 'lingo-noterminologypage' => "Page '$1' does not exist.",
1616 'lingo-terminologypagenotlocal' => "Page '$1' is not a local page.",
17 - 'lingo-noglossary' => 'NOGLOSSARY',
1817 );
1918
2019 /** Message documentation (Message documentation) */
2120 $messages['qqq'] = array(
2221 'lingo-desc' => '{{desc}}',
2322 'lingo-terminologypagename' => 'Name of the page where the terms and definitions of the glossary are stored',
24 - 'lingo-noglossary' => 'The magic word which will suppress the application of the glossary for a page.',
2523 );
2624
2725 /** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)
@@ -42,7 +40,6 @@
4341 'lingo-terminologypagename' => 'Glossar',
4442 'lingo-noterminologypage' => 'Seite „$1“ ist nicht vorhanden.',
4543 'lingo-terminologypagenotlocal' => 'Seite „$1“ befindet sich nicht auf diesem Wiki.',
46 - 'lingo-noglossary' => 'KEIN_GLOSSAR',
4744 );
4845
4946 /** French (Français)
Index: trunk/extensions/Lingo/Lingo.php
@@ -28,12 +28,26 @@
2929 // set default for Terminology page (null = take from i18n)
3030 $wgexLingoPage = null;
3131
 32+// set if glossary terms are to be marked up once or always
 33+$wgexLingoDisplayOnce = false;
3234
 35+
 36+// set extension credits
 37+// (no description here, will be set later)
 38+$wgExtensionCredits['parserhook']['lingo'] = array(
 39+ 'path' => __FILE__,
 40+ 'name' => 'Lingo',
 41+ 'author' => array('Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]'),
 42+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo',
 43+ 'version' => LINGO_VERSION,
 44+);
 45+
3346 // server-local path to this file
3447 $dir = dirname( __FILE__ );
3548
36 -// register message file
 49+// register message files
3750 $wgExtensionMessagesFiles['Lingo'] = $dir . '/Lingo.i18n.php';
 51+$wgExtensionMessagesFiles['LingoMagic'] = $dir . '/Lingo.i18n.magic.php';
3852
3953 // register class files with the Autoloader
4054 $wgAutoloadClasses['LingoHooks'] = $dir . '/LingoHooks.php';
@@ -47,8 +61,6 @@
4862 // register hook handlers
4963 $wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set credits
5064 $wgHooks['ParserAfterTidy'][] = 'LingoHooks::parse'; // parse page
51 -//$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup
52 -$wgHooks['LanguageGetMagic'][] = 'LingoHooks::setMagicWords'; // set magic words
5365
5466 // register resource modules with the Resource Loader
5567 $wgResourceModules['ext.Lingo.Styles'] = array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r90080Register magic.i18n file for Translatewiki per r89977raymond20:23, 14 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89895* followup r89860: magic word renamed and internationalized...foxtrott21:38, 11 June 2011

Status & tagging log