globalize-webpack-plugin icon indicating copy to clipboard operation
globalize-webpack-plugin copied to clipboard

How to support dynamic currencies

Open brenwell opened this issue 9 years ago • 3 comments

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.

brenwell avatar Feb 08 '16 12:02 brenwell

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.

rxaviers avatar Feb 11 '16 12:02 rxaviers

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

brenwell avatar Feb 12 '16 09:02 brenwell

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

rxaviers avatar Jul 20 '18 19:07 rxaviers