r81960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81959‎ | r81960 | r81961 >
Date:11:53, 11 February 2011
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Since 1.17 a whole lot of extensions have sprouted *.i18n.magic.php files. Most of these files have entries which erroneously omit the English synonym for a magic word. This breaks the extension completely when an affected language is selected.

This patch automatically includes synonyms from the fallback localisation, and prevents the case flag from being overridden, thus making extensions resistant to translator error.
Modified paths:
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LocalisationCache.php
@@ -95,7 +95,7 @@
9696 * by a fallback sequence.
9797 */
9898 static public $mergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames',
99 - 'dateFormats', 'defaultUserOptionOverrides', 'magicWords', 'imageFiles',
 99+ 'dateFormats', 'defaultUserOptionOverrides', 'imageFiles',
100100 'preloadedMessages',
101101 );
102102
@@ -118,6 +118,11 @@
119119 static public $optionalMergeKeys = array( 'bookstoreList' );
120120
121121 /**
 122+ * Keys for items that are formatted like $magicWords
 123+ */
 124+ static public $magicWordKeys = array( 'magicWords' );
 125+
 126+ /**
122127 * Keys for items where the subitems are stored in the backend separately.
123128 */
124129 static public $splitKeys = array( 'messages' );
@@ -181,7 +186,8 @@
182187 self::$mergeableMapKeys,
183188 self::$mergeableListKeys,
184189 self::$mergeableAliasListKeys,
185 - self::$optionalMergeKeys
 190+ self::$optionalMergeKeys,
 191+ self::$magicWordKeys
186192 ) );
187193 }
188194 return isset( $this->mergeableKeys[$key] );
@@ -426,6 +432,8 @@
427433 if ( isset( $value['inherit'] ) ) {
428434 unset( $value['inherit'] );
429435 }
 436+ } elseif ( in_array( $key, self::$magicWordKeys ) ) {
 437+ $this->mergeMagicWords( $value, $fallbackValue );
430438 }
431439 }
432440 } else {
@@ -433,6 +441,19 @@
434442 }
435443 }
436444
 445+ protected function mergeMagicWords( &$value, $fallbackValue ) {
 446+ foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
 447+ if ( !isset( $value[$magicName] ) ) {
 448+ $value[$magicName] = $fallbackInfo;
 449+ } else {
 450+ $oldSynonyms = array_slice( $fallbackInfo, 1 );
 451+ $newSynonyms = array_slice( $value[$magicName], 1 );
 452+ $synonyms = array_unique( array_merge( $oldSynonyms, $newSynonyms ) );
 453+ $value[$magicName] = array_merge( array( $fallbackInfo[0] ), $synonyms );
 454+ }
 455+ }
 456+ }
 457+
437458 /**
438459 * Given an array mapping language code to localisation value, such as is
439460 * found in extension *.i18n.php files, iterate through a fallback sequence

Follow-up revisions

RevisionCommit summaryAuthorDate
r819611.17wmf1: MFT r81960catrope11:58, 11 February 2011
r82221* Fix for r81960: List the local magic word synonyms first, so that they will...tstarling07:24, 16 February 2011
r85151MFT: r82000, r82004, r82020, r82025, r82038, r82039, r82048, r82070, r82081, ...demon20:39, 1 April 2011
r85348Fixes for r85151: grab Resources.php changes for r81719, r81721, r81722, r822...demon17:41, 4 April 2011

Comments

#Comment by Hashar (talk | contribs)   16:47, 6 June 2011

With all the follow up, and since it got merged to live site, can we assume this revision is now ok ?

Status & tagging log