r112177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112176‎ | r112177 | r112178 >
Date:01:22, 23 February 2012
Author:pgehres
Status:ok
Tags:
Comment:
Updating RapidHTML after r112175 and r112171. Partial revert of r111992
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/RapidHtml.php
@@ -264,7 +264,9 @@
265265 $html = str_replace( $matches[ 0 ][ $i ], wfMsg( $msg_key, $params ), $html );
266266 } else {
267267 // look for a country variant of the message and use that if found
268 - $html = str_replace( '%' . $msg_key . '%', $this->get_message_variation( $msg_key ), $html );
 268+ $msg_text = DataValidator::wfLangSpecificFallback( $this->getEscapedValue( 'language' ),
 269+ array( $msg_key . '-' . strtolower( $this->getEscapedValue( 'country' ) ), $msg_key ) );
 270+ $html = str_replace( '%' . $msg_key . '%', $msg_text, $html );
269271 }
270272 }
271273
@@ -443,53 +445,6 @@
444446 }
445447
446448 /**
447 - * This function looks for a country variant of the specified message and
448 - * returns the variant if found for the current language. If the variant
449 - * does not have a message for the current language, the original message
450 - * is used (checking first the current language and then falling back as
451 - * is normal for wfMessage).
452 - *
453 - * @param $key The original message key to be evaluated
454 - * @return string A string representing the message requested
455 - */
456 - function get_message_variation( $key ) {
457 - $langCode = strtolower( $this->getEscapedValue( 'language' ) );
458 - $countryCode = strtolower( $this->getEscapedValue( 'country' ) );
459 -
460 - # construct the country-specific message key
461 - $msg_alt_key = $key . '-' . $countryCode;
462 - $msg_alt = wfMessage( $msg_alt_key );
463 -
464 - # load the default
465 - $to_return = wfMessage( $key )->inLanguage( $langCode )->text();
466 -
467 - # check to see if an alternate exists
468 - if ( $msg_alt->exists() ){
469 - # get the English version of the alternate message
470 - $msg_alt_en = $msg_alt->inLanguage( 'en' )->text();
471 - # get the alternate message in the current language
472 - $msg_alt_lang = $msg_alt->inLanguage( $langCode )->text();
473 -
474 - # if we are looking for English, we're good
475 - if ( $langCode == 'en' ){
476 - $to_return = $msg_alt_en;
477 - }
478 - # check make sure we didn't fallback to English
479 - elseif ( strcmp( $msg_alt_en, $msg_alt_lang ) != 0 ){
480 - $to_return = $msg_alt_lang;
481 - }
482 - else {
483 - # do nothing and return the original message
484 - }
485 - }
486 -
487 - # strip the damned colons off of the right end
488 - $to_return = rtrim( $to_return, ':' );
489 -
490 - return $to_return;
491 - }
492 -
493 - /**
494449 * Gets a list of the supported countries from the parent class
495450 * and returns an option list representing all of those countries
496451 * in a translatable fashion.

Follow-up revisions

RevisionCommit summaryAuthorDate
r112262MFT r111992, r111993, r112177, r112187, r112188khorn23:10, 23 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111992Adding two functions to RapidHTML to genericize the country dropdowns in the ...pgehres08:18, 21 February 2012
r112171Updating wmfMessageExists to actully do what we want. Adding wfLangSpecificF...pgehres00:41, 23 February 2012
r112175A few little changes for khorn. FU r112171pgehres01:11, 23 February 2012

Status & tagging log