rxaviers / globalize-webpack-plugin

Globalize.js webpack plugin
Other
33 stars 27 forks source link

How to support dynamic currencies #15

Open brenwell opened 8 years ago

brenwell commented 8 years ago

Hey there, I am back with a couple more stupid questions. But I have decided to split them as they are unrelated.

First, My project requires multiple currencies and languages. I cloned the JQuery/globalize/examples/app-npm-webpack/ project and changed the code in index.js to the following

var Globalize = require( "globalize" );
var codes = ["USD","EUR","CAD","AUD","GBP","SEK"]
var cc = codes[randomInt] // get a random currency
var currencyFormatter = Globalize.currencyFormatter(cc);
document.getElementById( "currency" ).textContent = currencyFormatter( 69900 );

And I get build fails with No Globalize compiled data module found. I assume you are parsing the project for the supported currency codes, but is there a way to list the needed currency codes aswell?

Thanks again.

rxaviers commented 8 years ago

You need a formatter for each currency, please see https://github.com/jquery-support/globalize-compiler/issues/10#issuecomment-173571256

If you want to contribute, it would be great if we could update docs to include that information.

Thanks and feel free to post additional comments if you have further questions.

brenwell commented 8 years ago

Ok I understand. Thank you.

I have actually fallen back to using toLocaleString() for the moment as it is so easy to implement.

However I suspect I will be back to try again with Globalize, and when I do I will be happy to contribute. Thanks

rxaviers commented 6 years ago

Brainstorming potential solutions here https://github.com/globalizejs/globalize-compiler/issues/10#issuecomment-406702647