Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | * by a fallback sequence. |
97 | 97 | */ |
98 | 98 | static public $mergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames', |
99 | | - 'dateFormats', 'defaultUserOptionOverrides', 'magicWords', 'imageFiles', |
| 99 | + 'dateFormats', 'defaultUserOptionOverrides', 'imageFiles', |
100 | 100 | 'preloadedMessages', |
101 | 101 | ); |
102 | 102 | |
— | — | @@ -118,6 +118,11 @@ |
119 | 119 | static public $optionalMergeKeys = array( 'bookstoreList' ); |
120 | 120 | |
121 | 121 | /** |
| 122 | + * Keys for items that are formatted like $magicWords |
| 123 | + */ |
| 124 | + static public $magicWordKeys = array( 'magicWords' ); |
| 125 | + |
| 126 | + /** |
122 | 127 | * Keys for items where the subitems are stored in the backend separately. |
123 | 128 | */ |
124 | 129 | static public $splitKeys = array( 'messages' ); |
— | — | @@ -181,7 +186,8 @@ |
182 | 187 | self::$mergeableMapKeys, |
183 | 188 | self::$mergeableListKeys, |
184 | 189 | self::$mergeableAliasListKeys, |
185 | | - self::$optionalMergeKeys |
| 190 | + self::$optionalMergeKeys, |
| 191 | + self::$magicWordKeys |
186 | 192 | ) ); |
187 | 193 | } |
188 | 194 | return isset( $this->mergeableKeys[$key] ); |
— | — | @@ -426,6 +432,8 @@ |
427 | 433 | if ( isset( $value['inherit'] ) ) { |
428 | 434 | unset( $value['inherit'] ); |
429 | 435 | } |
| 436 | + } elseif ( in_array( $key, self::$magicWordKeys ) ) { |
| 437 | + $this->mergeMagicWords( $value, $fallbackValue ); |
430 | 438 | } |
431 | 439 | } |
432 | 440 | } else { |
— | — | @@ -433,6 +441,19 @@ |
434 | 442 | } |
435 | 443 | } |
436 | 444 | |
| 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 | + |
437 | 458 | /** |
438 | 459 | * Given an array mapping language code to localisation value, such as is |
439 | 460 | * found in extension *.i18n.php files, iterate through a fallback sequence |