How do I translate the payment form placeholder text?

The Stripe extension payment form has placeholder values that are automatically translated by Stripe. By default, they use the visitor’s browser locale.

The payment form translated into German.

These placeholders cannot be translated via the usual methods because the form is loaded in an iframe, so we’ve shown how to translate them below.

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

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

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

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

This Stripe document shows which locales they support.

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.