-
Notifications
You must be signed in to change notification settings - Fork 215
docs for how to use the polyfil #49
Comments
Do you mean how to use Consider the following code built to use the browser's native document.addEventListener('DOMContentLoaded', function () {
var nf = new Intl.NumberFormat(undefined, {style:'currency', currency:'USD'});
document.getElementById('widgetprice').textContent = nf.format(19.99);
}); Using the polyfill to support this code is complicated. For example: <script src="/js/Intl.min.js"></script>
<script>document.write(
'<script src="/locale-data/'+ (navigator.language||navigator.userLanguage) +'.js"><\/script>'
)</script> This isn't robust because it's possible we don't have a file to match the user's locale. So we'd have to write an asynchronous fetch of the file with a fallback in case of a 404, which means we're changing the way people would normally use the Internationalisation API (e.g. they'd have to wait for a callback before they could use it). The most robust approach is to implement the code for choosing the correct datafile at the server, based on the I'm happy to hear what you guys think we should do, @caridy, @drewfish and @ericf. |
yes, I don't think anyone will end up doing this the if computation of the locale-data is something that we want to people will do very often in the client side, then we should think about providing an array with all available locales or at least a filter method under the polyfill to pick the closest locale, so they can leverage that to be sure that the file is available. but in might experience, the whitelist of available locales for a particular application is normally an small subset from the available locale-data of the polyfill, and should be controlled by the app owner, something like this:
and that method back to the main subject, I was referencing to the fact that the polyfill is going to define |
Well we can at least sort that out right away. I'll do something about that shortly. |
Might be its own issue, but relevant to this one is how native functions like In the Chrome JavaScript console without
but after adding a
Should
|
readme.md doesn't provide any example
The text was updated successfully, but these errors were encountered: