获取 iOS 版 Safari 中的系统区域
在我的网络应用程序中,有一个货币金额的输入。 我正在使用 React 货币输入字段 对其进行格式化。
在我的手机上,我将语言设置为西班牙语,并将区域设置为台湾。 它们的小数点分隔符分别是逗号、
和点.
。
问题是 iOS 显示数字键盘时使用点作为分隔符,而库需要逗号。结果是根本不可能插入分隔符。
标准键盘会影响用户体验,所以这是不可能的。
window.navigator.locale
方法返回语言代码:es-ES。但是,就我而言,我需要检索设备的区域。
有什么方法可以检索系统区域吗?如果没有,网络应用程序是否应将区域定义为可选设置?
In my web app there is an input for the amount with currency.
I'm using React Currency Input Field to format it.
On my phone I have language set to Spanish and region set to Taiwan.
Their decimal separators are comma ,
and dot .
respectively.
The problem is that iOS displays the numeric keyboard with dot as a separator, while the library expects a comma. In a result it is not possible to insert a separator at all.
Standard keyboard would affect the UX so it is out of the question.
The method window.navigator.locale
returns language code: es-ES. However, in my case I need to retrieve a device's region.
Is there any method to retrieve system region? If not, shall the web app have region defined as the optional settings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
集思广益后,我们得出结论,无法确定系统偏好。
我们为语言和区域添加了可选的单独配置,以便用户可以决定是否坚持系统配置或覆盖它。
After brainstorming, we concluded that it was impossible to determine system preferences.
We have added an optional separate configuration for language and region so that the user can decide whether to stick with the system configuration or overwrite it.