Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/57456


Change subject: (bug 46720) attempt PayPal localization
......................................................................

(bug 46720) attempt PayPal localization

This is working for one-time donations, but currently does not for
recurring donations.  The API params seem to be correct, so I'm
assuming this is a bug or docbug on PP's end, for the moment.

There are really strange problems with the way we're forced to
specify locale, for example, they have full spanish translation,
but the interface will not appear in Spanish unless you happen to
be located in Spain (or falsify the "country=ES" param...)

Change-Id: I6afd7f57c6c2e7f7d26c18804c5eef13804404ef
---
M paypal_gateway/paypal.adapter.php
1 file changed, 55 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/56/57456/1

diff --git a/paypal_gateway/paypal.adapter.php 
b/paypal_gateway/paypal.adapter.php
index f70b345..e7681f7 100644
--- a/paypal_gateway/paypal.adapter.php
+++ b/paypal_gateway/paypal.adapter.php
@@ -35,6 +35,7 @@
        function defineStagedVars() {
                $this->staged_vars = array(
                        'recurring_length',
+                       'locale',
                );
        }
 
@@ -48,6 +49,7 @@
                        'custom' => 'contribution_tracking_id',
                        'a3' => 'amount',
                        'srt' => 'recurring_length',
+                       'lc' => 'locale',
                );
        }
 
@@ -86,6 +88,7 @@
                                'no_note',
                                'return',
                                'custom',
+                               'lc',
                        ),
                        'values' => array(
                                'business' => $this->account_config[ 
'AccountEmail' ],
@@ -115,6 +118,7 @@
                                'p3',
                                'src',
                                'srt',
+                               'lc',
                        ),
                        'values' => array(
                                'business' => $this->account_config[ 
'AccountEmail' ],
@@ -182,4 +186,55 @@
                        unset( $this->staged_data['recurring_length'] );
                }
        }
+
+       protected function stage_locale( $mode = 'request' ) {
+               $supported_countries = array(
+                       'AU',
+                       'AT',
+                       'BE',
+                       'BR',
+                       'CA',
+                       'CH',
+                       'CN',
+                       'DE',
+                       'ES',
+                       'GB',
+                       'FR',
+                       'IT',
+                       'NL',
+                       'PL',
+                       'PT',
+                       'RU',
+                       'US',
+               );
+               $supported_full_locales = array(
+                       'da_DK',
+                       'he_IL',
+                       'id_ID',
+                       'jp_JP',
+                       'no_NO',
+                       'pt_BR',
+                       'ru_RU',
+                       'sv_SE',
+                       'th_TH',
+                       'tr_TR',
+                       'zh_CN',
+                       'zh_HK',
+                       'zh_TW',
+               );
+
+               $this->log("locale");
+               if ( in_array( $this->staged_data['country'], 
$supported_countries ) ) {
+                       $this->staged_data['locale'] = 
$this->staged_data['country'];
+               }
+
+               $fallbacks = Language::getFallbacksFor( strtolower( 
$this->staged_data['language'] ) );
+               foreach ( $fallbacks as $lang ) {
+                       $locale = 
"{$this->staged_data['language']}_{$this->staged_data['country']}";
+                       if ( in_array( $locale, $supported_full_locales ) ) {
+                               $this->staged_data['locale'] = $locale;
+                               return;
+                       }
+               }
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/57456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6afd7f57c6c2e7f7d26c18804c5eef13804404ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to