Simple Membership Plugin › Forums › Simple Membership Plugin › Stripe Checkout box translation › Reply To: Stripe Checkout box translation
Hi, I found the code which popup Stripe checkout box was translated successfully!
Here is the original code in plugins/simple-membership/views/payments/payment-gateway/stripe_button_shortcode_view.php.
Could you read the key points in this order?: ※1→※2→※3
/* === Stripe Buy Now Button Form === */
$output = '';
$output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
$output .= "<form action='" . $notify_url . "' METHOD='POST'> ";
$output .= "<div style='display: none !important'>";
$output .= "<script src='https://checkout.stripe.com/checkout.js' class='stripe-button'
data-key='" . $publishable_key . "'
※2 This line was removed because it affected data-locale='auto'. By removing this line, "pay" was translated.
data-panel-label='Pay'
data-amount='{$price_in_cents}'
data-name='{$item_name}'";
※1 I found that web browser didn't read these three lines.
When these three were put into above $output, web browser read these, and Stripe checkout box was translated successfully except currency and "Pay" translation.
$output .= "data-description='{$payment_amount} {$payment_currency}'";
$output .= "data-locale='auto'";
$output .= "data-label='{$button_text}'"; //Stripe doesn't currenty support button image for their standard checkout.
※3 This line includes two key points for translating currency symbol.
First, this line needed to be put just after data-locale line. Order was important.
Second, I think {$payment_currency} output uppercase letters. However data-currency needed lowercase letters.
Two key points were needed at the same time in order to translate currency symbol.
(I didn't know how to change uppercase letters into lowercase letters here, so that I wrote 'jpy' directly at the moment. Could you help me?)
$output .= "data-currency='{$payment_currency}'";
if (!empty($item_logo)) {//Show item logo/thumbnail in the stripe payment window
$output .= "data-image='{$item_logo}'";
}
if (!empty($billing_address)) {//Show billing address in the stipe payment window
$output .= "data-billing-address='true'";
}
$output .= apply_filters('swpm_stripe_additional_checkout_data_parameters', ''); //Filter to allow the addition of extra data parameters for stripe checkout.
$output .= "></script>";
$output .= '</div>';
Here is the code Stripe checkout box translated successfully. Transaction worked successfully as well.
/* === Stripe Buy Now Button Form === */
$output = '';
$output .= '<div class="swpm-button-wrapper swpm-stripe-buy-now-wrapper">';
$output .= "<form action='" . $notify_url . "' METHOD='POST'> ";
$output .= "<div style='display: none !important'>";
$output .= "<script src='https://checkout.stripe.com/checkout.js' class='stripe-button'
data-key='" . $publishable_key . "'
data-amount='{$price_in_cents}'
data-name='{$item_name}'
data-description='{$payment_amount} {$payment_currency}'
data-locale='auto'
data-currency='jpy'
data-label='{$button_text}'//Stripe doesn't currenty support button image for their standard checkout.
if (!empty($item_logo)) {//Show item logo/thumbnail in the stripe payment window
data-image='{$item_logo}'
}
if (!empty($billing_address)) {//Show billing address in the stipe payment window
data-billing-address='true'
}
";
$output .= apply_filters('swpm_stripe_additional_checkout_data_parameters', ''); //Filter to allow the addition of extra data parameters for stripe checkout.
$output .= "></script>";
$output .= '</div>';
In this code, I wrote data-currency=’jpy’ directly.
If the issue of this part can be solved and you think this code is okay for everyone, could you consider of including this fix into next plugin update?
As always, thank you for wonderful plugin (and documentation which is very easy to understand) and your supports.
Best regards.