Building World-ready Applications in JavaScript Becoming a Reality


We consistently hear from developers that today’s JavaScript standard lacks a few basic objects and library helpers that are vital for building rich, world-wide Web applications. Last year, we shared a reference implementation of an emerging proposal for an Internationalization API for JavaScript. This API introduces support for number formatting, date and time formatting, and locale sensitive collation or string comparison. Given that this limitation fundamentally prevents world-ready sites from being written interoperably on the standards Web platform; the working group, which includes members from Amazon, Google, Mozilla, and Microsoft, have collaborated to finalize the draft specification ahead of the draft ECMAScript 6 specification. A couple of weeks ago, the standards committee met in the Computer Science department on the campus of Northeastern University and finalized the proposed API. We have updated our reference implementation to match the current draft of the specification.

We’ve also published a demo to illustrate the use of this API in to visualize Foreign Currency Exchange. This is a common Web scenario that today has to be written using a plug-in, a browser extension, or through interaction with the server. Play with the demo, open the JavaScript console to interact with the API, and give us feedback.

Charting Historical Foreign Currency Exchange with the Internationalization API

Perusing sites like Google Finance, Yahoo Finance, FXCM, ForXCharts, and other ForEx sites, a pattern emerges: all of these sites implement their user experience using a combination of plug-ins, extensions, or constructs which require server round-tripping for interactivity. Because these sites need to format currencies, present dates according to a specific locale, and sort strings like stock tickers with locale specific string comparison, the Web platform comes up short for them today.


1) Yahoo Finance ForEx Chart using Flash to format numbers 2) Google Finance using Flash to format DateTime

Aside from the ActiveX control which provides support for the API, the user experience of our ForEx test drive demo is written 100% in JavaScript. It uses jqPlot to chart the currency exchanges format dates and currencies in JavaScript. At the top of the demo, you can pick a Foreign Exchange pair, such as comparing EUR/JPY and view it with a locale specific date format by selecting the ja-JP-u-nu-latin language tag. When you hit the “Plot with Intl” you’ll see the JavaScript API in action.

Overview of the JavaScript Internationalization API

Web applications are harder to globalize than native applications because JavaScript does not provide access the native date and currency formats in the underlying OS. All JavaScript implementations run on top of operating systems that include comprehensive internationalization libraries that have varying degrees of support. With the introduction of this API, there will be a standard interface for accessing these libraries. The internationalization library in Windows 8 includes support for 364 available locales, 18 numbering systems, many date patterns, and includes support for the Gregorian, Islamic, Hebrew, Buddhist, Korean, and Japanese calendars.

For the purpose of this test drive demo, the reference implementation of the emerging standard is implemented as an ActiveX extension, but once installed and enabled it works just like the planned JavaScript API will work. You can even experiment with it in the JavaScript console window.

The API itself enables three basic capabilities to the Web platform:

  • Number formatting – Format numbers with specified decimal lengths or as a currency or percentage
  • Date and Time formatting – Converts a time value into a string provided inputs of time zone, second, minute, hour, day, month, year, weekday, or era
  • Ordinal String Comparison – Formally known as collation which does locale specific string comparison

Below you can find an example of the API in action:

// Number formatting
var nf = new Intl.NumberFormat(["en-US"], {
    style: "currency",
    currency: "CNY",
    currencyDisplay: "symbol",
    maxmimumFractionDigit: 1
})

nf.format(100); // "¥100.00"

// Date formatting
var dtf = new Intl.DateTimeFormat(["ar-SA-u-ca-islamic-nu-latin"], {
    weekday: "long"
});
dtf.format(new Date()); // Prints today's week day in long format

//Collation sample
var co = new Intl.Collator(["de-DE-u-co-phonebk"]);
co.compare("a", "b"); // returns -1

Next steps for the ECMAScript Standard

While the internationalization API is in the process of being ratified, the standards committee continues to refine the list of proposals for the next version of the standard, ECMAScript 6, which is targeted to be completed in 2013. As with the internationalization API, we welcome feedback on these proposals to ensure that we’re able to faithfully represent the needs of Web developers when the standards committee meets every few months.

The best way to get a feel for the proposals is to experiment with the reference implementations. We encourage you to play with the sample app or play with the prototype API in the JavaScript console to see how it feels. Once you’ve tried it out, let us know if you have any feedback or suggestions. We look forward to improving JavaScript and making it ever easier to build great Web applications using standard APIs.

— Suresh Jayabalan & Amanda Silver, Program Managers, JavaScript Team


Comments (41)

  1. Anonymous says:

    Looks like there's no reason there couldn't be a pure-JavaScript implementation of this. Is that right? Seems promising for a backwards-compatible rollout if so–sort of like how we use native and JS JSON objects, except that here the native version comes first.

    And, very cool.

  2. Anonymous says:

    We want 10 for 7!

  3. Anonymous says:

    Whichever may be sufficient as such a thing.

    If there is time to do such things, please release Internet Explorer 10 for Windows 7 early!

    It is likely to be hard to use Windows 8, and since its sushi reputation is bad, he does not buy it.

  4. Anonymous says:

    @japanese man, apparantly Win8 doesn't suit your mood.. not your type of a gadget.. mm..  But I would still insist, when it will be released on Oct 26th, give it a chance. Be it performance, design, hardware support, form-factors support, standards support, backward compatibility support, graphics support, interoprability or what ever factor you care most, compare it with other OSes. Dont "hear" things.. just make your own impression!

  5. Anonymous says:

    @Randall –

    I guess you could have a JavaScript implementation of this API, but it would be very very large (take the ICU library, for example, which, as far as I know, is an open source implementation of a superset of the data this API provides – it is an 8 MB binary) and so it would be unrealistic to load it every time (think of load/parse/initialization/run times, memory usage and similar). This is probably why web applications currently resort to server work.

  6. Anonymous says:

    The ECMAScript committee needs some serious ass-kicking to make them move faster.

    Seriously, I can't believe that the ECMAScript committee is only meeting every few months!

    How much time will we have to wait until browsers are able to interpret TypeScript natively? Months? Years? Decades?

  7. Anonymous says:

    @design-by-committee cancer –

    Beside meetings, there are active mailing lists, as far as I know.

    The W3C and the rest are doing the same. Active mailing lists and occasional meetings.

  8. Anonymous says:

    That's great.  Too bad Microsoft still doesn't support an input type of date control like every other platform that supports mobile / tablets!

    Or is that "slate"d for 2014?!

  9. Anonymous says:

    In IE9 when you for example watch a video on youtube or browsing a webpage with flash objects and after that you watch another video then when you start the video it shows in a split second the previously viewed video (or picture) before the new starts. I just don't know if it's a problem with IE or adobes flash player. It's the same all the time and I always update the flash player.

    It often shows previously viewed things in the flash player.

  10. Anonymous says:

    Awesome! 3 whole weeks until Windows 8 is RTM launched and the promised Windows 7 version of the IE10 browser for beta testing is still MIA!

    There's no time left to do full regression testing nor time for Microsoft to act on the bugs we would have found!

    Thus IE10 is the first IE browser since IE8 to hit the market with next-to-none testing done by developers and the dev community.

    This is a recipe for failure and I certainly hope that the public does not hold back on their feelings when the bugs roll in… This is "Microsoft's iOS6 maps disaster".

    We've already told clients that Metro IE10 will not be supported (we're not taking the fall for Microsoft's usability issues and horrible UX)… And it looks like IE10 for Windows will be unsupported too (until full testing can be done and it can be determined if IE10 is an upgrade or a downgrade.

    So glad you took the time over the past 2-3 months to answer all the developer questions and respond to the numerous issues put forth regarding the insane whitelist scheme.  A truly shameful moment in development history when a Monopoly puts their attempt to gain market share before the usability and security of their users!

    A crying shame.

  11. Anonymous says:

    Joel – Good god, man, lay off the caffeine and get a grip.  Windows 8 and IE 10 have been a free download for everyone since May 31st.

    ie.microsoft.com/…/Default.html

    Don't call me in the morning.

  12. Anonymous says:

    Windows 8 may have been available to those with MSDN subscriptions but not every web developer on the planet has a spare PC lying around to upgrade the OS on just to test the latest IE browser.

    The failure of Microsoft to deliver on yet another promise is exactly why developers are starting to detest Microsoft.

    It's no surprise that the good developers like Chris Wilson and Eric Lawrence got up and left – I would have quit too!

    Developers were not going to waste time and money on hardware to test IE10 when a Windows 7 version was promised to developers ***Before*** IE10 on Windows 8 went to RTM! And Microsoft failed to deliver.

    The flash list submission process is a joke and has been exposed as a scam that no site or app developer can even qualify for.  Best of all the users suffer because of Microsofts blatant incompetency.

  13. Anonymous says:

    If you can get your stuff working in IE9 but not IE10 then you should probably just quit web design right now.

  14. Anonymous says:

    Internet Explorer 9 Commercial (The Honest Version)

    http://www.youtube.com/watch

    ———————————————————————————–

    If The Internet Explorer 9 Commercial Was Honest | TechCrunch

    techcrunch.com/…/if-the-internet-explorer-9-commercial-was-honest

  15. Anonymous says:

    "not every web developer on the planet has a spare PC lying around to upgrade the OS on just to test the latest IE browser."

    Then run it in a VM idiot. Bleah.  Troll with 100 different names

  16. Anonymous says:

    we want 10

  17. Anonymous says:

    I'm not one of these whiners, but I tried multiple times and windows 8 just plain refuses to run on VM with my laptop.  Says its a problem with my processor or something.

  18. Anonymous says:

    In this blog of yours, I found so many interesting themes and even if I did not yet responded to none, you to  know that I read them with great interest. Success.

  19. Anonymous says:

    Not only will running in a VM not properly indicate how multiple monitor interaction will be but the GPU performance is not accurate.

    More importantly installing and running an entire OS just to test a browser is insane because now I have to install MS Office to test direct downloads to Word or Excel, WinZip to test downloading a zip file Adobe Reader to test PDFs and Adobe Flash to test extended features.

    Microsoft provided preview browsers in the past I see no reason why they can't easily do the same this time for Windows 7.  Well actually I can… Because it takes time and they forced an RTM date of Oct. 26th they were rushed, finalized the browser long before it was ready and they are likely working night and day to resolve it with a day one patch for Windows 8.

    I think we would all be fine with this as an explanation if they actually came forth and indicated they are working on the clumbsy interface quirks on the desktop, the usability issues and security holes. However for now we sit here with no info getting very worried that Microsoft is about to release the most un-usable browser ever causing all of us a major support nightmare.

    4 words are all we need to hear: "we're working on it"

    The silence is killing us! (And the broken asp post back forms!!! Yikes wasn't this issue documented back in like 2006?!?! Just fix it already! It makes it look like you have no web skills whatsoever!

  20. Anonymous says:

    Whine and cry all out want.  IE10 will be ready when its done.  If you don't like it, move to OS-X or Linux

  21. Anonymous says:

    IE10 may be ready when it's done, but will it be done when it's ready?

  22. Anonymous says:

    ie10 in downloading become freeze . of course in tab changing ?!

    firefox is beter in multitasking.

  23. Anonymous says:

    @Arieta – Software is never actually "done"; that would mean "bug-free", but no software will ever be bug-free.

  24. Anonymous says:

    @George: Numerous versions of Hello World would disagree with that statement, but yeah, thanks for pointing out what I meant with my last comment.

  25. Anonymous says:

    Windows 7 version?!?!? It's only been 2 or 3 months that we've been waiting for the release you promised!

    Flash censorship list?!?! Are you going to make a comment about this? Or just wait until the public gives windows 8 a horrible review because the metro browser is useless and opens up security holes when forcing users to use the desktop version leaving their metro session wide open?

    Are you going to be addressing all the usability issues? Especially those in metro IE on the desktop?

    When are you going to fix multi-monitor support in metro? It looks retarded on the smallest of my 3 screens and blank on the other two!

    Or how about just like replying to **ANY** comment here on the IE Blog?  We realize that Microsoft is stuck in waterfall development but that shouldn't stop you from keeping us informed and pretending you value our feedback especially when we expose your bugs, security holes, usability & design flaws.

    With just over 2 weeks to RTM it doesn't provide much time to fix all the issues! You could at least keep us calm by indicating you are at least addressing all the issues internally!

    Ps can you fix this comment form?!? It's insane that such a major bug has been left untouched on this platform for years!!!

  26. Anonymous says:

    Would be possible in the near future to just discontinue the internet explorer development ? All the developers know that IE is just a pain and the worst browser available so why IE / microsoft developers don't get it ? You should just get a chrome or firefox build and add a new skin . It would be faster, safer and richer in terms of features (HTML5)

  27. Anonymous says:

    Most of those "worst browser" complaints come from people that haven't really used IE since 6/7.

  28. Anonymous says:

    I want use IE10 for Win 7.

    Harry Release!!

  29. Anonymous says:

    What does "maxmimumFractionDigit: 1" do?

    Was it supposed to be "maximumFractionDigit: 1" followd by "nf.format(100); // "¥100.0""?

  30. Anonymous says:

    I have found a worrying bug in IE10 RTM.  Seems it breaks a lot of websites when they use ajax post with jquery.

    For example try and post a comment on stackoverflow.com or github.com – you get an error message.

    For some reason in IE10 it is posting nothing (content length = 0) – switch it back to IE9 standards mode and everything works.

    I wasn't sure where to put this feedback.  Didn't really feel like jumping through hoops on your connect.microsoft.com site

  31. Anonymous says:

    Is that Ajax post bug in IE10 desktop?, metro? Or both?

  32. Anonymous says:

    If you're not running win8 in a VM to test your website because you don't have multimon in your VM tool, I hate to think what your site looks like that you need to spread it across two screens 😉 Seriously, separate evaluating the OS and the browser as different ideas.

  33. Anonymous says:

    @Sean, this blog is not about the bug, its about new features. You can always use http://translator.bing.com or http://translatro.google.com if you have problems in reading English language.

    Hope it help you understand what the author is talking about.

    @Mihai, don't confuse IE with chrome. And ask google to stop that privacy voilating crime-ware…

  34. Anonymous says:

    @Sean I haven't used IE10 Metro.  I am finding lots and lots of sites that are quite broken. Including this blog and even the new azure portal windows.azure.com

  35. Anonymous says:

    @Maverix, exactly which control is broken on windows.azure.com? Please enlighten us.

  36. Anonymous says:

    @Tod in the new azure portal (html version) IE10 gets an error message when trying to load the monitoring page.  If I switch the document mode to IE9 standards it works perfectly.  I'm finding I can't post comments in facebook, stackoverflow and many other sites.  I am finding it hard to believe that i'm the only one experiencing this issue.

  37. Anonymous says:

    I can't even get this page to work correctly in IE10.  It won't show the comments until I switch the document mode back to IE9 standards.

    I'm running Windows 8 Pro RTM with IE10 RTM 10.0.9200.16384.  I haven't tested any of this in the metro version – because frankly metro sucks

  38. Anonymous says:

    @Maverix, which version of Windows 8 are you running? I am using RTM and comments on FB and SO are working just fine. I cannot confirm the azure as of this moment. But I would suggest you to reset IE10. Settings > Internet Options > Advanced > Reset.

    Hope it helps.

  39. Anonymous says:

    I am using IE metro and it works great btw.. It has same rendering and JavaScript engine like IE desktop. I like the full screen view is a nice experience and the position of back/forward buttons.

  40. Anonymous says:

    @tod will try that out. I am starting to suspect it could be something only happening to me. I haven't heard anyone else complaining.

  41. Anonymous says:

    Okay so everything works great in metro IE10 and it isn't working correctly in the desktop version.

    @Tod can you try using the IE10 desktop version?  Would love to see if it just me or not