1. Documentation /
  2. Stripe WooCommerce Extension /
  3. Customizing the Stripe WooCommerce Extension /
  4. How do I translate the payment form placeholder text?

How do I translate the payment form placeholder text?

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

Screenshot indicating the placeholder text seen in a Stripe credit card form
Card field placeholder text localized in French.

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.
    • 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 not using the new checkout experience, you can change this locale with the wc_stripe_elements_options filter.

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.

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.