简体   繁体   English

如何在 Stripe 中更改结帐表单的语言?

[英]How do I change the language of the checkout form in Stripe?

I have noticed that with the Stripe checkout form, the language seems to be fixed in English.我注意到使用 Stripe 结帐表格时,语言似乎是固定的英语。

Is there a way for me to change this language to, for example, Spanish, Japanese or Chinese?我有没有办法将此语言更改为例如西班牙语、日语或中文?

I'm currently using the default form code on the Stripe documentation:我目前正在使用 Stripe 文档中的默认表单代码:

<form action="/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_variable_here"
    data-image="/img/documentation/checkout/marketplace.png"
    data-name="My Company Pty Ltd"
    data-description="2 widgets"
    data-currency="aud"
    data-amount="2000">
  </script>
</form>

EDIT : Updating the answer since it's the accepted one to make sure it's visible.编辑更新答案,因为它是被接受的,以确保它是可见的。

Stripe released a feature that allows you to have Stripe Checkout display in other languages automatically. Stripe发布了一项功能,允许您自动以其他语言显示 Stripe Checkout。

The easiest solution is to pass data-locale="auto" to display Checkout in the user's preferred language, if available .最简单的解决方案是传递data-locale="auto"以用户首选语言(如果可用)显示 Checkout。 English will be used by default.默认情况下将使用英语。 You can also force a specific locale in data-locale as long as it's one officially supported by Stripe.您还可以在data-locale设置中强制使用特定区域设置,只要它是 Stripe 官方支持的区域设置。

Late answer but I think it can help someone.迟到的答案,但我认为它可以帮助某人。 Add line: data-locale: "language" to your script.在脚本中添加行: data-locale: "language" Example:例子:

<form action="/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_variable_here"
    data-locale="fr"
    data-image="/img/documentation/checkout/marketplace.png"
    data-name="My Company Pty Ltd"
    data-description="2 widgets"
    data-currency="aud"
    data-amount="2000">
  </script>
</form>

Stripe released a new version of Checkout last year which does language localization automatically based on the browser's locale setting. Stripe 去年发布了新版本的 Checkout ,它会根据浏览器的区域设置自动进行语言本地化。 You can also manually override this behavior by passing in a locale when creating a Checkout Session.您还可以通过在创建 Checkout Session 时传入语言环境来手动覆盖此行为。

您可以使用“locale”参数来更改Stripe上的结帐语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM