r102419 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102418‎ | r102419 | r102420 >
Date:18:09, 8 November 2011
Author:khorn
Status:ok (Comments)
Tags:
Comment:
More changes surrounding staging an appropriate language for GlobalCollect (and later, more gateways).
r102364
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
@@ -1331,12 +1331,63 @@
13321332
13331333 protected function stage_language( $type = 'request' ) {
13341334 $language = strtolower( $this->staged_data['language'] );
1335 - switch ( $language ){
1336 - case 'zh' :
1337 - $this->staged_data['language'] = 'sc';
1338 - break;
 1335+
 1336+ $count = 0;
 1337+ //Count's just there making sure we don't get stuck here.
 1338+ while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){
 1339+ //find the failback.
 1340+ $language = $this->dataObj->getFailbackLanguage( $language );
 1341+ $count += 1;
13391342 }
 1343+
 1344+ if ( !in_array( $language, $this->getAvailableLanguages() ) ){
 1345+ $language = 'en';
 1346+ }
 1347+
 1348+ if ( $language === 'zh' ) { //Handles GC's mutant Chinese code.
 1349+ $language = 'sc';
 1350+ }
 1351+
 1352+ $this->staged_data['language'] = $language;
13401353 }
 1354+
 1355+ /**
 1356+ * OUR language codes which are available to use in GlobalCollect.
 1357+ * @return string
 1358+ */
 1359+ function getAvailableLanguages(){
 1360+ $languages = array(
 1361+ 'ar', //Arabic
 1362+ 'cz', //Czech
 1363+ 'da', //Danish
 1364+ 'nl', //Dutch
 1365+ 'en', //English
 1366+ 'fa', //Farsi
 1367+ 'fi', //Finish
 1368+ 'fr', //French
 1369+ 'de', //German
 1370+ 'he', //Hebrew
 1371+ 'hi', //Hindi
 1372+ 'hu', //Hungarian
 1373+ 'it', //Italian
 1374+ 'ja', //Japanese
 1375+ 'ko', //Korean
 1376+ 'no', //Norwegian
 1377+ 'po', //Polish
 1378+ 'pt', //Portuguese
 1379+ 'ro', //Romanian
 1380+ 'sl', //Slovene
 1381+ 'es', //Spanish
 1382+ 'sw', //Swahili
 1383+ 'sv', //Swedish
 1384+ 'th', //Thai
 1385+ 'tr', //Turkish
 1386+ 'ur', //Urdu
 1387+ 'vi', //Vietnamese
 1388+ 'zh', //the REAL chinese code.
 1389+ );
 1390+ return $languages;
 1391+ }
13411392
13421393 /**
13431394 * Stage: amount
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -944,6 +944,25 @@
945945 );
946946 return $stomp_fields;
947947 }
 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+ }
948967 }
949968
950969 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r102421MFT r102364, r102419awjrichards18:55, 8 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102364Stages chinese language codes specially for communication with GlobalCollect.khorn02:11, 8 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   20:58, 8 November 2011

Finish now! ;)

Status & tagging log