Stripe为什么不本地化我的付款元素字段和错误消息?

huangapple go评论65阅读模式
英文:

Why isn't Stripe localising my Payment Element's fields and error messages?

问题

Stripe Elements(即Stripe.js),包括Payment Element,显然现在支持本地化/国际化,并且文档中的locale参数表示默认情况下它会检测浏览器的语言环境并相应地更改消息:

locale string
用于显示占位符和错误字符串的语言环境。默认为auto(Stripe会检测浏览器的语言环境)。

然而,当我将浏览器的语言设置为法语等其他语言时,无论是省略locale字段还是显式指定为locale: "auto",都不能将语言切换为法语 - 我只能通过手动指定locale: "fr"来强制实现这种行为,这似乎表明Stripe不能正确检测浏览器的语言环境。

这里发生了什么,我该如何让Stripe像文档所说的那样检测浏览器的语言环境?

英文:

Stripe Elements (i.e. Stripe.js), including the Payment Element, apparently now supports localisation/internationalisation out of the box, and the documentation for the locale parameter says it detects the browser's locale by default and changes the messaging to reflect this:

> locale string
> A locale to display placeholders and error strings in. Default is auto (Stripe detects the locale of the browser).

However, when I change my browser's language to French, for example, neither omitting the locale field nor explicitly specifying it with locale: "auto" translates the language to French - I can only force this behaviour by manually specifying locale: "fr", which seems to suggest that Stripe isn't detecting the browser locale correctly.

What's going on here, and how can I get Stripe to detect the browser's locale like the documentation says it's capable of?

答案1

得分: 1

这是由于Firefox布局语言设置的方式造成的。它们将设置分为两部分。在 about:preferences > 语言 下,您看到的下拉菜单是用于浏览器菜单的。在下拉菜单的正下方,您会看到“选择用于显示页面的首选语言”,右侧有一个“选择”按钮。当单击该按钮时,将打开“Web页面语言设置”。如果您在这里添加法语并将其移至语言列表的顶部,您应该会看到PaymentElement以法语呈现。

英文:

This is due to how Firefox lays out language settings. They split settings in two. Under about:preferences > Language, the dropdown menu you see there is for browser menus. Immediately below the dropdown, you'll see "Choose your preferred language for displaying pages" with a "Choose" button to the right. When clicked, that button opens up "Webpage Language Settings". If you add French here and move it to the top of the language list, you should see the PaymentElement rendered in French.

huangapple
  • 本文由 发表于 2023年6月22日 01:46:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76525925.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定