Unable to translate Stripe Payment Element form

Created on 12 May 2025, 5 days ago

Problem/Motivation

At the moment I don't see a way to show the Stripe Payment Element in the current language set by the user. The form defaults to english.

Proposed resolution

We could modify the JS to provide the "locale" option like this when creating the Stripe class:

const stripe = Stripe('your-publishable-key', {
  locale: drupalSettings.path.currentLanguage || 'auto'
});

const elements = stripe.elements();
// Continue with creating and mounting the Payment Element
✨ Feature request
Status

Active

Version

2.0

Component

Payment Element

Created by

πŸ‡ͺπŸ‡ΈSpain lluisandreu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lluisandreu
  • πŸ‡ΊπŸ‡ΈUnited States TomTech

    Stripe Payment Element defaults to "auto" support for languages/locales based on the browser's indicated locale.

    See list here: https://docs.stripe.com/js/appendix/supported_locales

    See also here: https://support.stripe.com/questions/payment-element-faq

    Are you visiting the site using a browser configured with one of the supported locales/languages? If so, this would seem to be a Stripe issue in their browser detection.

    If you are visiting the site with the browser configured to one language, but the site configured to another, this is a different scenario.

    If you are doing testing, then you would likely just need to update your browser settings to properly test this.

    If you are specifically wanting a site that handles different configurable languages, regardless of the browser language configuration,
    this is a more complex scenario, and not certain we want to take over Stripe's auto-detection to support this. (If we did, we would need to, at a minimum: 1) ensure the locale names map 1:1 with Stripe's. More than likely, we would need a mapping Enum to handle this. 2) determine what to do for languages Stripe doesn't support, but Drupal does.)

Production build 0.71.5 2024