How do I translate the payment form placeholder text?

When the payment form is loaded by the Stripe extension, the fields will have placeholder text. These placeholders are automatically translated by Stripe.

The payment form translated into German.

By default, Stripe detects the locale of the browser and uses that as the default.

These placeholders cannot be translated through your site since the form is loaded in an iframe — meaning that it’s not technically on your site, and Stripe handles the translation on their end. This means that some of the standard methods for translation and localization outlined here will not work.

If you are using the legacy checkout experience, you can change this locale with the wc_stripe_elements_options filter. For example, to change the placeholder text to use the site locale, you can use this snippet:

add_filter( 'wc_stripe_elements_options', 'wc_update_locale_in_stripe_element_options' );
function wc_update_locale_in_stripe_element_options( $options ) {
    return array_merge(
        $options,
        array(
            'locale' => get_locale(),
        )
    );
};

Alternatively, you can replace the get_locale() string with your preferred locale value. Here is a similar snippet that will force the placeholder text in the Stripe card fields to be localized in Italian:

add_filter( 'wc_stripe_elements_options', 'wc_update_locale_in_stripe_element_options' );
function wc_update_locale_in_stripe_element_options( $options ) {
    return array_merge(
        $options,
        array(
            'locale' => 'it',
        )
    );
};

You can review which locales are supported by the Stripe payment element at this link.

NOTE: We are unable to provide support for custom code under our Support Policy. If you need to customize a snippet further or extend its functionality, we highly recommend Codeable or a Certified WooExpert.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.