Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -353,7 +353,8 @@ |
354 | 354 | array( $checker, 'XhtmlCheck' ), |
355 | 355 | array( $checker, 'braceBalanceCheck' ), |
356 | 356 | array( $checker, 'pagenameMessagesCheck' ), |
357 | | - array( $checker, 'miscMWChecks' ) |
| 357 | + array( $checker, 'miscMWChecks' ), |
| 358 | + array( $checker, 'prefMessagesCheck' ), |
358 | 359 | ) ); |
359 | 360 | |
360 | 361 | return $checker; |
Index: trunk/extensions/Translate/groups/MediaWiki/Checker.php |
— | — | @@ -247,4 +247,65 @@ |
248 | 248 | } |
249 | 249 | } |
250 | 250 | } |
| 251 | + |
| 252 | + /** |
| 253 | + * Checks that messages used for some preferences are not equal, otherwise Special:Preferences may explode |
| 254 | + * (bug 28152). |
| 255 | + * |
| 256 | + * @param $messages \array Iterable list of TMessage objects. |
| 257 | + * @param $code \string Language code of the translations. |
| 258 | + * @param $warnings \array Array where warnings are appended to. |
| 259 | + */ |
| 260 | + protected function prefMessagesCheck( $messages, $code, &$warnings ) { |
| 261 | + $prefs = self::getPrefMessages(); |
| 262 | + |
| 263 | + foreach ( $messages as $message ) { |
| 264 | + foreach ( $prefs as $group ) { |
| 265 | + if ( !in_array( $message->key(), $group ) ) { |
| 266 | + continue; |
| 267 | + } |
| 268 | + $conflicts = array(); |
| 269 | + foreach ( $group as $key ) { |
| 270 | + if ( $key == $message->key() ) { |
| 271 | + continue; |
| 272 | + } |
| 273 | + if ( $message->translation() == wfMessage( $key )->inLanguage( $code )->text() ) { |
| 274 | + $conflicts[] = $key; |
| 275 | + } |
| 276 | + } |
| 277 | + if ( count( $conflicts ) ) { |
| 278 | + $conflicts = preg_replace( '/^(.*)$/', "[[MediaWiki:$1/$code|$1]]", $conflicts ); |
| 279 | + global $wgLang; |
| 280 | + $warnings[$message->key()][] = array( |
| 281 | + array( 'prefmessages', 'match', $message->key(), $code ), |
| 282 | + 'translate-checks-prefs', |
| 283 | + $wgLang->listToText( $conflicts ), |
| 284 | + ); |
| 285 | + } |
| 286 | + } |
| 287 | + } |
| 288 | + } |
| 289 | + |
| 290 | + /** |
| 291 | + * Returns an array of message keys that may cause conflicts for prefMessagesCheck() |
| 292 | + * @return \array |
| 293 | + */ |
| 294 | + protected static function getPrefMessages() { |
| 295 | + // @todo: moar? |
| 296 | + return array( |
| 297 | + array( |
| 298 | + 'Mw_math_png', |
| 299 | + 'Mw_math_simple', |
| 300 | + 'Mw_math_html', |
| 301 | + 'Mw_math_source', |
| 302 | + 'Mw_math_modern', |
| 303 | + 'Mw_math_mathml', |
| 304 | + ), |
| 305 | + array( |
| 306 | + 'Gender-male', |
| 307 | + 'Gender-female', |
| 308 | + 'Gender-unknown', |
| 309 | + ), |
| 310 | + ); |
| 311 | + } |
251 | 312 | } |
Index: trunk/extensions/Translate/Translate.i18n.php |
— | — | @@ -145,6 +145,7 @@ |
146 | 146 | 'translate-checks-format' => 'This translation does not follow the definition or has invalid syntax: $1', |
147 | 147 | 'translate-checks-escape' => 'The following escapes may be accidental: <strong>$1</strong>', |
148 | 148 | 'translate-checks-fudforum-syntax' => 'Use <nowiki>$1</nowiki> instead of <nowiki>$2</nowiki> in this project.', |
| 149 | + 'translate-checks-prefs' => 'Message conflicts with $1. These messages must not be the same.', |
149 | 150 | |
150 | 151 | 'translate-pref-nonewsletter' => 'Do not send me e-mail newsletters', |
151 | 152 | 'translate-pref-editassistlang' => 'Assistant languages:', |