mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Locale is now saved in DB
This commit is contained in:
parent
2938a5c6d4
commit
3aa81bd144
3 changed files with 46 additions and 62 deletions
|
@ -110,8 +110,7 @@ return array(
|
|||
$container->get( 'button.early-wc-checkout-validation-enabled' ),
|
||||
$container->get( 'button.pay-now-contexts' ),
|
||||
$container->get( 'wcgateway.funding-sources-without-redirect' ),
|
||||
$container->get( 'woocommerce.logger.woocommerce' ),
|
||||
$container->get( 'wcgateway.paypal-locale' )
|
||||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'button.url' => static function ( ContainerInterface $container ): string {
|
||||
|
|
|
@ -197,13 +197,6 @@ class SmartButton implements SmartButtonInterface {
|
|||
*/
|
||||
private $session_handler;
|
||||
|
||||
/**
|
||||
* The locale.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
* SmartButton constructor.
|
||||
*
|
||||
|
@ -227,7 +220,6 @@ class SmartButton implements SmartButtonInterface {
|
|||
* @param array $pay_now_contexts The contexts that should have the Pay Now button.
|
||||
* @param string[] $funding_sources_without_redirect The sources that do not cause issues about redirecting (on mobile, ...) and sometimes not returning back.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param string $locale The locale.
|
||||
*/
|
||||
public function __construct(
|
||||
string $module_url,
|
||||
|
@ -249,8 +241,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
bool $early_validation_enabled,
|
||||
array $pay_now_contexts,
|
||||
array $funding_sources_without_redirect,
|
||||
LoggerInterface $logger,
|
||||
string $locale
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
|
||||
$this->module_url = $module_url;
|
||||
|
@ -1213,8 +1204,10 @@ class SmartButton implements SmartButtonInterface {
|
|||
$params['enable-funding'] = implode( ',', array_unique( $enable_funding ) );
|
||||
}
|
||||
|
||||
if ( $this->settings->has( 'smart_button_locale_override' ) && $this->settings->get( 'smart_button_locale_override' ) ) {
|
||||
$params['locale'] = $this->locale;
|
||||
$locale = $this->settings->has( 'smart_button_language' ) ? $this->settings->get( 'smart_button_language' ) : '';
|
||||
|
||||
if ( $locale ) {
|
||||
$params['locale'] = $locale;
|
||||
}
|
||||
|
||||
return $params;
|
||||
|
|
|
@ -1425,54 +1425,46 @@ return array(
|
|||
'wcgateway.wp-paypal-locales-map' => static function( ContainerInterface $container ): array {
|
||||
return array(
|
||||
'' => __( 'Browser language', 'woocommerce-paypal-payments' ),
|
||||
'ar-DZ' => __( 'Arabic (Algeria)', 'woocommerce-paypal-payments' ),
|
||||
'ar-BH' => __( 'Arabic (Bahrain)', 'woocommerce-paypal-payments' ),
|
||||
'ar-EG' => __( 'Arabic (Egypt)', 'woocommerce-paypal-payments' ),
|
||||
'ar-JO' => __( 'Arabic (Jordan)', 'woocommerce-paypal-payments' ),
|
||||
'ar-KW' => __( 'Arabic (Kuwait)', 'woocommerce-paypal-payments' ),
|
||||
'ar-MA' => __( 'Arabic (Morocco)', 'woocommerce-paypal-payments' ),
|
||||
'ar-SA' => __( 'Arabic (Saudi Arabia)', 'woocommerce-paypal-payments' ),
|
||||
'cs-CZ' => __( 'Czech', 'woocommerce-paypal-payments' ),
|
||||
'zh-CN' => __( 'Chinese (Simplified)', 'woocommerce-paypal-payments' ),
|
||||
'zh-HK' => __( 'Chinese (Hong Kong)', 'woocommerce-paypal-payments' ),
|
||||
'zh-TW' => __( 'Chinese (Traditional)', 'woocommerce-paypal-payments' ),
|
||||
'da-DK' => __( 'Danish', 'woocommerce-paypal-payments' ),
|
||||
'nl-NL' => __( 'Dutch', 'woocommerce-paypal-payments' ),
|
||||
'en-AU' => __( 'English (Australia)', 'woocommerce-paypal-payments' ),
|
||||
'en-GB' => __( 'English (United Kingdom)', 'woocommerce-paypal-payments' ),
|
||||
'en-US' => __( 'English (United States)', 'woocommerce-paypal-payments' ),
|
||||
'fi-FI' => __( 'Finnish', 'woocommerce-paypal-payments' ),
|
||||
'fr-CA' => __( 'French (Canada)', 'woocommerce-paypal-payments' ),
|
||||
'fr-FR' => __( 'French (France)', 'woocommerce-paypal-payments' ),
|
||||
'de-DE' => __( 'German (Germany)', 'woocommerce-paypal-payments' ),
|
||||
'de-CH' => __( 'German (Switzerland)', 'woocommerce-paypal-payments' ),
|
||||
'de-AT' => __( 'German (Austria)', 'woocommerce-paypal-payments' ),
|
||||
'de-LU' => __( 'German (Luxembourg)', 'woocommerce-paypal-payments' ),
|
||||
'el-GR' => __( 'Greek', 'woocommerce-paypal-payments' ),
|
||||
'he-IL' => __( 'Hebrew', 'woocommerce-paypal-payments' ),
|
||||
'hu-HU' => __( 'Hungarian', 'woocommerce-paypal-payments' ),
|
||||
'id-ID' => __( 'Indonesian', 'woocommerce-paypal-payments' ),
|
||||
'it-IT' => __( 'Italian', 'woocommerce-paypal-payments' ),
|
||||
'ja-JP' => __( 'Japanese', 'woocommerce-paypal-payments' ),
|
||||
'ko-KR' => __( 'Korean', 'woocommerce-paypal-payments' ),
|
||||
'no-NO' => __( 'Norwegian', 'woocommerce-paypal-payments' ),
|
||||
'es-ES' => __( 'Spanish (Spain)', 'woocommerce-paypal-payments' ),
|
||||
'es-MX' => __( 'Spanish (Mexico)', 'woocommerce-paypal-payments' ),
|
||||
'pl-PL' => __( 'Polish', 'woocommerce-paypal-payments' ),
|
||||
'pt-BR' => __( 'Portuguese (Brazil)', 'woocommerce-paypal-payments' ),
|
||||
'pt-PT' => __( 'Portuguese (Portugal)', 'woocommerce-paypal-payments' ),
|
||||
'ru-RU' => __( 'Russian', 'woocommerce-paypal-payments' ),
|
||||
'sk-SK' => __( 'Slovak', 'woocommerce-paypal-payments' ),
|
||||
'sv-SE' => __( 'Swedish', 'woocommerce-paypal-payments' ),
|
||||
'th-TH' => __( 'Thai', 'woocommerce-paypal-payments' ),
|
||||
'ar_DZ' => __( 'Arabic (Algeria)', 'woocommerce-paypal-payments' ),
|
||||
'ar_BH' => __( 'Arabic (Bahrain)', 'woocommerce-paypal-payments' ),
|
||||
'ar_EG' => __( 'Arabic (Egypt)', 'woocommerce-paypal-payments' ),
|
||||
'ar_JO' => __( 'Arabic (Jordan)', 'woocommerce-paypal-payments' ),
|
||||
'ar_KW' => __( 'Arabic (Kuwait)', 'woocommerce-paypal-payments' ),
|
||||
'ar_MA' => __( 'Arabic (Morocco)', 'woocommerce-paypal-payments' ),
|
||||
'ar_SA' => __( 'Arabic (Saudi Arabia)', 'woocommerce-paypal-payments' ),
|
||||
'cs_CZ' => __( 'Czech', 'woocommerce-paypal-payments' ),
|
||||
'zh_CN' => __( 'Chinese (Simplified)', 'woocommerce-paypal-payments' ),
|
||||
'zh_HK' => __( 'Chinese (Hong Kong)', 'woocommerce-paypal-payments' ),
|
||||
'zh_TW' => __( 'Chinese (Traditional)', 'woocommerce-paypal-payments' ),
|
||||
'da_DK' => __( 'Danish', 'woocommerce-paypal-payments' ),
|
||||
'nl_NL' => __( 'Dutch', 'woocommerce-paypal-payments' ),
|
||||
'en_AU' => __( 'English (Australia)', 'woocommerce-paypal-payments' ),
|
||||
'en_GB' => __( 'English (United Kingdom)', 'woocommerce-paypal-payments' ),
|
||||
'en_US' => __( 'English (United States)', 'woocommerce-paypal-payments' ),
|
||||
'fi_FI' => __( 'Finnish', 'woocommerce-paypal-payments' ),
|
||||
'fr_CA' => __( 'French (Canada)', 'woocommerce-paypal-payments' ),
|
||||
'fr_FR' => __( 'French (France)', 'woocommerce-paypal-payments' ),
|
||||
'de_DE' => __( 'German (Germany)', 'woocommerce-paypal-payments' ),
|
||||
'de_CH' => __( 'German (Switzerland)', 'woocommerce-paypal-payments' ),
|
||||
'de_AT' => __( 'German (Austria)', 'woocommerce-paypal-payments' ),
|
||||
'de_LU' => __( 'German (Luxembourg)', 'woocommerce-paypal-payments' ),
|
||||
'el_GR' => __( 'Greek', 'woocommerce-paypal-payments' ),
|
||||
'he_IL' => __( 'Hebrew', 'woocommerce-paypal-payments' ),
|
||||
'hu_HU' => __( 'Hungarian', 'woocommerce-paypal-payments' ),
|
||||
'id_ID' => __( 'Indonesian', 'woocommerce-paypal-payments' ),
|
||||
'it_IT' => __( 'Italian', 'woocommerce-paypal-payments' ),
|
||||
'ja_JP' => __( 'Japanese', 'woocommerce-paypal-payments' ),
|
||||
'ko_KR' => __( 'Korean', 'woocommerce-paypal-payments' ),
|
||||
'no_NO' => __( 'Norwegian', 'woocommerce-paypal-payments' ),
|
||||
'es_ES' => __( 'Spanish (Spain)', 'woocommerce-paypal-payments' ),
|
||||
'es_MX' => __( 'Spanish (Mexico)', 'woocommerce-paypal-payments' ),
|
||||
'pl_PL' => __( 'Polish', 'woocommerce-paypal-payments' ),
|
||||
'pt_BR' => __( 'Portuguese (Brazil)', 'woocommerce-paypal-payments' ),
|
||||
'pt_PT' => __( 'Portuguese (Portugal)', 'woocommerce-paypal-payments' ),
|
||||
'ru_RU' => __( 'Russian', 'woocommerce-paypal-payments' ),
|
||||
'sk_SK' => __( 'Slovak', 'woocommerce-paypal-payments' ),
|
||||
'sv_SE' => __( 'Swedish', 'woocommerce-paypal-payments' ),
|
||||
'th_TH' => __( 'Thai', 'woocommerce-paypal-payments' ),
|
||||
);
|
||||
},
|
||||
'wcgateway.paypal-locale' => static function( ContainerInterface $container ): string {
|
||||
$locale = get_user_locale();
|
||||
$wp_paypal_locale_map = $container->get( 'wcgateway.wp-paypal-locales-map' );
|
||||
|
||||
$locale = $wp_paypal_locale_map[ $locale ] ?? $locale;
|
||||
|
||||
return apply_filters( 'woocommerce_paypal_payments_button_locale_override', $locale );
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue