Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -1106,8 +1106,69 @@ |
1107 | 1107 | 'payment_submethod', |
1108 | 1108 | 'issuer_id', |
1109 | 1109 | 'order_id', //This may or may not oughta-be-here... |
| 1110 | + 'language', |
1110 | 1111 | ); |
1111 | 1112 | } |
| 1113 | + |
| 1114 | + protected function stage_language( $type = 'request' ) { |
| 1115 | + $language = strtolower( $this->staged_data['language'] ); |
| 1116 | + |
| 1117 | + $count = 0; |
| 1118 | + //Count's just there making sure we don't get stuck here. |
| 1119 | + while ( !in_array( $language, $this->getAvailableLanguages() ) && $count < 3 ){ |
| 1120 | + //find the failback. |
| 1121 | + $language = $this->dataObj->getFailbackLanguage( $language ); |
| 1122 | + $count += 1; |
| 1123 | + } |
| 1124 | + |
| 1125 | + if ( !in_array( $language, $this->getAvailableLanguages() ) ){ |
| 1126 | + $language = 'en'; |
| 1127 | + } |
| 1128 | + |
| 1129 | + if ( $language === 'zh' ) { //Handles GC's mutant Chinese code. |
| 1130 | + $language = 'sc'; |
| 1131 | + } |
| 1132 | + |
| 1133 | + $this->staged_data['language'] = $language; |
| 1134 | + } |
| 1135 | + |
| 1136 | + /** |
| 1137 | + * OUR language codes which are available to use in GlobalCollect. |
| 1138 | + * @return string |
| 1139 | + */ |
| 1140 | + function getAvailableLanguages(){ |
| 1141 | + $languages = array( |
| 1142 | + 'ar', //Arabic |
| 1143 | + 'cz', //Czech |
| 1144 | + 'da', //Danish |
| 1145 | + 'nl', //Dutch |
| 1146 | + 'en', //English |
| 1147 | + 'fa', //Farsi |
| 1148 | + 'fi', //Finish |
| 1149 | + 'fr', //French |
| 1150 | + 'de', //German |
| 1151 | + 'he', //Hebrew |
| 1152 | + 'hi', //Hindi |
| 1153 | + 'hu', //Hungarian |
| 1154 | + 'it', //Italian |
| 1155 | + 'ja', //Japanese |
| 1156 | + 'ko', //Korean |
| 1157 | + 'no', //Norwegian |
| 1158 | + 'po', //Polish |
| 1159 | + 'pt', //Portuguese |
| 1160 | + 'ro', //Romanian |
| 1161 | + 'sl', //Slovene |
| 1162 | + 'es', //Spanish |
| 1163 | + 'sw', //Swahili |
| 1164 | + 'sv', //Swedish |
| 1165 | + 'th', //Thai |
| 1166 | + 'tr', //Turkish |
| 1167 | + 'ur', //Urdu |
| 1168 | + 'vi', //Vietnamese |
| 1169 | + 'zh', //the REAL chinese code. |
| 1170 | + ); |
| 1171 | + return $languages; |
| 1172 | + } |
1112 | 1173 | |
1113 | 1174 | /** |
1114 | 1175 | * Stage: amount |
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -946,6 +946,25 @@ |
947 | 947 | ); |
948 | 948 | return $stomp_fields; |
949 | 949 | } |
| 950 | + |
| 951 | + /** |
| 952 | + * getFailbackLanguage should return the code for a next-best-language, in |
| 953 | + * the event it is deemed unavailable by the gateway. |
| 954 | + * @param string $unavailable_language |
| 955 | + * @return string The code which the unavailable language should fail back |
| 956 | + * to. |
| 957 | + */ |
| 958 | + function getFailbackLanguage( $unavailable_language ){ |
| 959 | + $unavailable_language = strtolower($unavailable_language); |
| 960 | + |
| 961 | + //TODO: Something in here more complicated than defaulting to English. |
| 962 | + //Probably get a failback from MediaWiki if one exists, and if the code |
| 963 | + //doesn't change as part of that process, have a next-best language |
| 964 | + //identifier that we write? |
| 965 | + |
| 966 | + $failback = 'en'; |
| 967 | + return strtolower($failback); |
| 968 | + } |
950 | 969 | } |
951 | 970 | |
952 | 971 | ?> |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
953 | 972 | Merged /trunk/extensions/DonationInterface/gateway_common/DonationData.php:r102419 |
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface |
___________________________________________________________________ |
Modified: svn:mergeinfo |
954 | 973 | Merged /trunk/extensions/DonationInterface:r102364,102419 |