r85816 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85815‎ | r85816 | r85817 >
Date:19:11, 11 April 2011
Author:ialex
Status:deferred
Tags:
Comment:
Simplify magic word definition
Modified paths:
  • /trunk/extensions/ArrayExtension/ArrayExtension.i18n.magic.php (modified) (history)
  • /trunk/extensions/ArrayExtension/ArrayExtension.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArrayExtension/ArrayExtension.php
@@ -53,11 +53,11 @@
5454 'version' => ArrayExtension::VERSION
5555 );
5656
57 -$wgExtensionMessagesFiles['ArrayExtension'] = dirname( __FILE__ ) . '/ArrayExtension.i18n.php';
 57+$dir = dirname( __FILE__ );
5858
59 -$wgHooks['LanguageGetMagic'][] = 'efArrayExtensionLanguageGetMagic';
 59+$wgExtensionMessagesFiles['ArrayExtension'] = $dir . '/ArrayExtension.i18n.php';
 60+$wgExtensionMessagesFiles['ArrayExtensionMagic'] = $dir . '/ArrayExtension.i18n.magic.php';
6061
61 -
6262 /**
6363 * named arrays - an array has a list of values, and could be set to a SET
6464 */
@@ -778,13 +778,3 @@
779779
780780 return true;
781781 }
782 -
783 -function efArrayExtensionLanguageGetMagic( &$magicWords, $langCode ) {
784 - require_once( dirname( __FILE__ ) . '/ArrayExtension.i18n.magic.php' );
785 -
786 - foreach ( efArrayExtensionWords( $langCode ) as $word => $trans ) {
787 - $magicWords[$word] = $trans;
788 - }
789 -
790 - return true;
791 -}
Index: trunk/extensions/ArrayExtension/ArrayExtension.i18n.magic.php
@@ -9,43 +9,25 @@
1010 * @licence MIT License
1111 */
1212
13 -/**
14 - * Get translated magic words, if available
15 - *
16 - * @param string $lang Language code
17 - *
18 - * @return array
19 - */
20 -function efArrayExtensionWords( $lang ) {
21 - $words = array();
 13+$magicWords = array();
2214
23 - /**
24 - * English
25 - */
26 - $words['en'] = array(
27 - 'arraydefine' => array( 0, 'arraydefine' ),
 15+$magicWords['en'] = array(
 16+ 'arraydefine' => array( 0, 'arraydefine' ),
2817
29 - 'arrayprint' => array( 0, 'arrayprint' ),
30 - 'arraysize' => array( 0, 'arraysize' ),
31 - 'arrayindex' => array( 0, 'arrayindex' ),
32 - 'arraysearch' => array( 0, 'arraysearch' ),
 18+ 'arrayprint' => array( 0, 'arrayprint' ),
 19+ 'arraysize' => array( 0, 'arraysize' ),
 20+ 'arrayindex' => array( 0, 'arrayindex' ),
 21+ 'arraysearch' => array( 0, 'arraysearch' ),
3322
34 - 'arrayunique' => array( 0, 'arrayunique' ),
35 - 'arraysort' => array( 0, 'arraysort' ),
36 - 'arrayreset' => array( 0, 'arrayreset' ),
 23+ 'arrayunique' => array( 0, 'arrayunique' ),
 24+ 'arraysort' => array( 0, 'arraysort' ),
 25+ 'arrayreset' => array( 0, 'arrayreset' ),
3726
38 - 'arraymerge' => array( 0, 'arraymerge' ),
39 - 'arrayslice' => array( 0, 'arrayslice' ),
 27+ 'arraymerge' => array( 0, 'arraymerge' ),
 28+ 'arrayslice' => array( 0, 'arrayslice' ),
4029
41 - 'arrayunion' => array( 0, 'arrayunion' ),
42 - 'arrayintersect' => array( 0, 'arrayintersect' ),
43 - 'arraydiff' => array( 0, 'arraydiff' ),
44 - 'arraysearcharray' => array( 0, 'arraysearcharray' ),
45 - );
46 -
47 - # English is used as a fallback, and the English synonyms are
48 - # used if a translation has not been provided for a given word
49 - return ( $lang == 'en' || !isset( $words[$lang] ) )
50 - ? $words['en']
51 - : array_merge( $words['en'], $words[$lang] );
52 -}
 30+ 'arrayunion' => array( 0, 'arrayunion' ),
 31+ 'arrayintersect' => array( 0, 'arrayintersect' ),
 32+ 'arraydiff' => array( 0, 'arraydiff' ),
 33+ 'arraysearcharray' => array( 0, 'arraysearcharray' ),
 34+);

Status & tagging log