Add GooglePay button language/locale

This commit is contained in:
Pedro Silva 2023-09-12 18:09:58 +01:00
parent e8b21ed044
commit c3e5d21e75
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
4 changed files with 63 additions and 2 deletions

View file

@ -55,6 +55,7 @@ return array(
'elements' => array(
'#field-googlepay_button_color',
'#field-googlepay_button_type',
'#field-googlepay_button_language',
'#field-googlepay_button_shipping_enabled',
),
),
@ -96,6 +97,22 @@ return array(
'gateway' => 'paypal',
'requirements' => array(),
),
'googlepay_button_language' => array(
'title' => str_repeat( ' ', 6 ) . __( 'Button Language', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
'description' => __(
'The language and region used for the displayed Google Pay button. The default value is the current language and region setting in a browser.',
'woocommerce-paypal-payments'
),
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => 'en',
'options' => PropertiesDictionary::button_languages(),
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
'requirements' => array(),
),
'googlepay_button_shipping_enabled' => array(
'title' => str_repeat( ' ', 6 ) . __( 'Shipping Callback', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',

View file

@ -149,6 +149,7 @@ class GooglepayButton {
allowedPaymentMethods: [baseCardPaymentMethod],
buttonColor: buttonStyle.color || 'black',
buttonType: buttonStyle.type || 'pay',
buttonLocale: buttonStyle.language || 'en',
buttonSizeMode: 'fill',
});
jQuery(wrapper).append(button);

View file

@ -390,6 +390,7 @@ class Button implements ButtonInterface {
$values = array(
'color' => 'black',
'type' => 'pay',
'language' => 'en',
);
foreach ( $values as $style => $value ) {

View file

@ -43,4 +43,46 @@ class PropertiesDictionary {
'subscribe' => __( 'Subscribe', 'woocommerce-paypal-payments' ),
);
}
/**
* Returns the possible list of button languages.
*
* @return array
*/
public static function button_languages(): array {
return array(
'' => __( 'Browser language', 'woocommerce-paypal-payments' ),
'ar' => __( 'Arabic', 'woocommerce-paypal-payments' ),
'bg' => __( 'Bulgarian', 'woocommerce-paypal-payments' ),
'ca' => __( 'Catalan', 'woocommerce-paypal-payments' ),
'zh' => __( 'Chinese', 'woocommerce-paypal-payments' ),
'hr' => __( 'Croatian', 'woocommerce-paypal-payments' ),
'cs' => __( 'Czech', 'woocommerce-paypal-payments' ),
'da' => __( 'Danish', 'woocommerce-paypal-payments' ),
'nl' => __( 'Dutch', 'woocommerce-paypal-payments' ),
'en' => __( 'English', 'woocommerce-paypal-payments' ),
'et' => __( 'Estonian', 'woocommerce-paypal-payments' ),
'fi' => __( 'Finnish', 'woocommerce-paypal-payments' ),
'fr' => __( 'French', 'woocommerce-paypal-payments' ),
'de' => __( 'German', 'woocommerce-paypal-payments' ),
'el' => __( 'Greek', 'woocommerce-paypal-payments' ),
'id' => __( 'Indonesian', 'woocommerce-paypal-payments' ),
'it' => __( 'Italian', 'woocommerce-paypal-payments' ),
'ja' => __( 'Japanese', 'woocommerce-paypal-payments' ),
'ko' => __( 'Korean', 'woocommerce-paypal-payments' ),
'ms' => __( 'Malay', 'woocommerce-paypal-payments' ),
'no' => __( 'Norwegian', 'woocommerce-paypal-payments' ),
'pl' => __( 'Polish', 'woocommerce-paypal-payments' ),
'pt' => __( 'Portuguese', 'woocommerce-paypal-payments' ),
'ru' => __( 'Russian', 'woocommerce-paypal-payments' ),
'sr' => __( 'Serbian', 'woocommerce-paypal-payments' ),
'sk' => __( 'Slovak', 'woocommerce-paypal-payments' ),
'sl' => __( 'Slovenian', 'woocommerce-paypal-payments' ),
'es' => __( 'Spanish', 'woocommerce-paypal-payments' ),
'sv' => __( 'Swedish', 'woocommerce-paypal-payments' ),
'th' => __( 'Thai', 'woocommerce-paypal-payments' ),
'tr' => __( 'Turkish', 'woocommerce-paypal-payments' ),
'uk' => __( 'Ukrainian', 'woocommerce-paypal-payments' ),
);
}
}