Reputation: 31
I am using globalize.js for currency formatting for different countries. Using this link I am able to achieve for USD, but I need USD and JPY or for any country. I followed all the tutorials mentioned in the globalize. Please anyone help me to solve this issue.
Upvotes: 1
Views: 3118
Reputation: 2889
You need to load the appropriate portions of CLDR, specifically main/currencies (e.g., https://github.com/unicode-cldr/cldr-numbers-modern/blob/master/main/en/currencies.json).
Follow an example using npm / node:
npm install globalize cldr-data
node
-
var Globalize = require('globalize');
Globalize.load(require('cldr-data').entireSupplemental());
Globalize.load(require('cldr-data').entireMainFor('en', 'de', 'ja'));
Globalize('en').formatCurrency(9.99, 'EUR')
// > '€9.99'
Globalize('de').formatCurrency(9.99, 'EUR')
// > '9,99 €'
Globalize('en').formatCurrency(10, 'JPY')
// > '¥10'
Globalize('ja').formatCurrency(10, 'JPY')
// > '¥10'
For more information about (or alternative ways of) how to get CLDR data or how to load CLDR data into Globalize, see https://github.com/jquery/globalize/blob/master/doc/cldr.md.
Upvotes: 1