r102463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102462‎ | r102463 | r102464 >
Date:23:19, 8 November 2011
Author:kaldari
Status:ok
Tags:fundraising 
Comment:
better fallback language support for DonationInterface
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1335,8 +1335,8 @@
13361336 $count = 0;
13371337 //Count's just there making sure we don't get stuck here.
13381338 while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){
1339 - //find the failback.
1340 - $language = $this->dataObj->getFailbackLanguage( $language );
 1339+ // Get the fallback language
 1340+ $language = Language::getFallbackFor( $language );
13411341 $count += 1;
13421342 }
13431343
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -471,12 +471,14 @@
472472
473473 /**
474474 * normalizeAndSanitize helper function.
475 - * If the language has not yet been set, pulls the language code
 475+ * If the language has not yet been set or is not valid, pulls the language code
476476 * from the current global language object.
477477 */
478478 function setLanguage() {
479479 global $wgLang;
480 - if ( !$this->isSomething( 'language' ) ) {
 480+ if ( !$this->isSomething( 'language' )
 481+ || !Language::isValidBuiltInCode( $this->normalized['language'] ) )
 482+ {
481483 $this->setVal( 'language', $wgLang->getCode() );
482484 }
483485 }
@@ -944,25 +946,6 @@
945947 );
946948 return $stomp_fields;
947949 }
948 -
949 - /**
950 - * getFailbackLanguage should return the code for a next-best-language, in
951 - * the event it is deemed unavailable by the gateway.
952 - * @param string $unavailable_language
953 - * @return string The code which the unavailable language should fail back
954 - * to.
955 - */
956 - function getFailbackLanguage( $unavailable_language ){
957 - $unavailable_language = strtolower($unavailable_language);
958 -
959 - //TODO: Something in here more complicated than defaulting to English.
960 - //Probably get a failback from MediaWiki if one exists, and if the code
961 - //doesn't change as part of that process, have a next-best language
962 - //identifier that we write?
963 -
964 - $failback = 'en';
965 - return strtolower($failback);
966 - }
967950 }
968951
969952 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011

Status & tagging log