国际化(数字格式化“num.toLocaleString()”)不适用于chrome [英] Internationalization(Number formatting "num.toLocaleString()") not working for chrome

查看:288
本文介绍了国际化(数字格式化“num.toLocaleString()”)不适用于chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Javascript中进行数字格式化...我使用以下方法
num.toLocaleString()这将适用于Firefox,IE但不适用于谷歌浏览器..
Wat我需要添加它在Chrome浏览器中工作。

i want do number formatting in Javascript.. and i use the following method num.toLocaleString() which will work for Firefox, IE but doesnt work for Google Chrome.. Wat i need to add for it work in chrome browser.

推荐答案

toLocaleString()方法依赖于实现依赖:它使用实现区域设置,例如浏览器区域设置。因此,如果我查看使用该方法的页面,我会看到根据芬兰语或英语语言环境格式化的数字,具体取决于我使用的浏览器。

The toLocaleString() method is by definition implementation-dependent: it uses the implementation locale, such as browser locale. So if I were looking at your page that uses the method, I would see numbers formatted according to Finnish or English locale, depending on which browser I’m using.

什么你想要的是页面的语言环境本地化,为此你还需要别的东西。在简单的情况下,您可以自己编写代码,但数字格式通常很复杂,因此使用库是合理的,例如全球化。查看简单的演示的简洁来源。在Globalize中,您在指定区域设置时使用标准语言代码

What you want is localization by the locale of the page, and for this you need something else. In simple cases you might code it yourself, but number formatting is in general complicated, making it reasonable to use a library, such as Globalize. Check out the compact source of a simple demo. In Globalize, you use standard language codes when specifying the locale.

这篇关于国际化(数字格式化“num.toLocaleString()”)不适用于chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆