Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -310,6 +310,10 @@ |
311 | 311 | * addWikiText will do the escaping for you. Use wfMsgHtml() |
312 | 312 | * if you need an escaped message. |
313 | 313 | * |
| 314 | + * Brace transformation is done *after* parameter replacement, so |
| 315 | + * constructs like {{plural:$1}} may be used. Be aware this may |
| 316 | + * have security implications for HTML message output. |
| 317 | + * |
314 | 318 | * @param $key String: lookup key for the message, usually |
315 | 319 | * defined in languages/Language.php |
316 | 320 | */ |
— | — | @@ -347,6 +351,10 @@ |
348 | 352 | * customize over 70 messages in order to, e.g., fix a link in every |
349 | 353 | * possible language. |
350 | 354 | * |
| 355 | + * Brace transformation is done *after* parameter replacement, so |
| 356 | + * constructs like {{plural:$1}} may be used. Be aware this may |
| 357 | + * have security implications for HTML message output. |
| 358 | + * |
351 | 359 | * @param $key String: lookup key for the message, usually |
352 | 360 | * defined in languages/Language.php |
353 | 361 | */ |
— | — | @@ -377,6 +385,10 @@ |
378 | 386 | |
379 | 387 | /** |
380 | 388 | * Get a message from the language file, for the UI elements |
| 389 | + * |
| 390 | + * Brace transformation is done *after* parameter replacement, so |
| 391 | + * constructs like {{plural:$1}} may be used. Be aware this may |
| 392 | + * have security implications for HTML message output. |
381 | 393 | */ |
382 | 394 | function wfMsgNoDB( $key ) { |
383 | 395 | $args = func_get_args(); |
— | — | @@ -386,6 +398,10 @@ |
387 | 399 | |
388 | 400 | /** |
389 | 401 | * Get a message from the language file, for the content |
| 402 | + * |
| 403 | + * Brace transformation is done *after* parameter replacement, so |
| 404 | + * constructs like {{plural:$1}} may be used. Be aware this may |
| 405 | + * have security implications for HTML message output. |
390 | 406 | */ |
391 | 407 | function wfMsgNoDBForContent( $key ) { |
392 | 408 | global $wgForceUIMsgAsContentMsg; |
— | — | @@ -401,6 +417,11 @@ |
402 | 418 | |
403 | 419 | /** |
404 | 420 | * Really get a message |
| 421 | + * |
| 422 | + * Brace transformation is done *after* parameter replacement, so |
| 423 | + * constructs like {{plural:$1}} may be used. Be aware this may |
| 424 | + * have security implications for HTML message output. |
| 425 | + * |
405 | 426 | * @return $key String: key to get. |
406 | 427 | * @return $args |
407 | 428 | * @return $useDB Boolean |
— | — | @@ -409,8 +430,14 @@ |
410 | 431 | function wfMsgReal( $key, $args, $useDB, $forContent=false, $transform = true ) { |
411 | 432 | $fname = 'wfMsgReal'; |
412 | 433 | |
413 | | - $message = wfMsgGetKey( $key, $useDB, $forContent, $transform ); |
| 434 | + $message = wfMsgGetKey( $key, $useDB, $forContent, false ); |
414 | 435 | $message = wfMsgReplaceArgs( $message, $args ); |
| 436 | + if( $transform && strstr( $message, '{{' ) !== false ) { |
| 437 | + global $wgParser, $wgMsgParserOptions; |
| 438 | + $old = $wgMsgParserOptions->setInterfaceMessage( !$forContent ); |
| 439 | + $message = $wgParser->transformMsg($message, $wgMsgParserOptions); |
| 440 | + $wgMsgParserOptions->setInterfaceMessage( $old ); |
| 441 | + } |
415 | 442 | return $message; |
416 | 443 | } |
417 | 444 | |
— | — | @@ -516,6 +543,9 @@ |
517 | 544 | * to pre-escape them if you really do want plaintext, or just wrap |
518 | 545 | * the whole thing in htmlspecialchars(). |
519 | 546 | * |
| 547 | + * Brace transformation is done *before* parameter replacement, so |
| 548 | + * constructs like {{plural:$1}} will not work. |
| 549 | + * |
520 | 550 | * @param string $key |
521 | 551 | * @param string ... parameters |
522 | 552 | * @return string |
— | — | @@ -533,6 +563,9 @@ |
534 | 564 | * to pre-escape them if you really do want plaintext, or just wrap |
535 | 565 | * the whole thing in htmlspecialchars(). |
536 | 566 | * |
| 567 | + * Brace transformation is done *before* parameter replacement, so |
| 568 | + * constructs like {{plural:$1}} will not work. |
| 569 | + * |
537 | 570 | * @param string $key |
538 | 571 | * @param string ... parameters |
539 | 572 | * @return string |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -359,6 +359,10 @@ |
360 | 360 | under HTML-compatible browsers. |
361 | 361 | * (bug 5077) Added hook 'BeforePageDisplay' to SkinTemplate::outputPage |
362 | 362 | * Replace fatally changed 'uploadnewversion' with 'uploadnewversion-linktext' |
| 363 | +* Move parameter replacement before brace transformations in most of the |
| 364 | + wfMsg() family (except for wfMsgHtml). This allows things like {{plural:}}, |
| 365 | + {{urlencode:}}, and {{fullurl:}} to be used in most cases correctly. |
| 366 | + The content or UI language will be used accordingly for (forContent)?. |
363 | 367 | |
364 | 368 | |
365 | 369 | == Compatibility == |