reepay / reepay-woocommerce-payment

Reepay Woocommerce Payment Plugin
https://wordpress.org/plugins/reepay-checkout-gateway/
6 stars 10 forks source link

v1.7.2: bug in “automatic language detection” #319

Open appeltju opened 5 months ago

appeltju commented 5 months ago

If you set “Language In Payment Window” to “Detect Automatically” the payment window is ALWAYS shown in English. And I think it’s a bug in the plugin:

Note that “Detect automatically” is defined as the empty string in ReepayCheckout.php:297 '' => __( 'Detect Automatically', 'reepay-checkout-gateway' )

Further note that the language setting is loaded in ReepayCheckout.php:76 $this->language = $this->settings['language'] ?: $this->language;

and keep in mind that the short-versioned ternary operator ?: interprets the empty string (== “Detect Automatically”) as false and will therefore not assign the empty string to $this->language. That is $this->language will be initialized with its current value, which is defined in ReepayGateway.php:94 public $language = 'en_US';

Due to this mistake, the method get_language is never actually executed and therefore neither is get_locale. Therefore the settings “Detect automatically” is effectively ignored and the payment window is shown in en_US, no matter the current WordPress locale.

This bug has existed since at least v1.7.0.