I have two methods i'm trying to write using globalize. One to format Numbers and one to format Currency.
function currencyFormatter(value, locale, fieldDefinition) {
var formatter = Globalize('en').currencyFormatter( 'INR' )
return formatter( value )
}
function numberFormatter(value, locale, fieldDefinition){
var formatter = Globalize('en').numberFormatter()
return formatter( value )
}
When I use the 'en' locale with 'INR' currency code for currencyFormatter or 'en' for numberFormatter i'm expecting to see something like ₹12,34,567.89 however what i get in both cases is something like ₹1,234,567.89 (minus currency symbol for number). I looked inside my node_modules folder cldr-data/main/en-IN/numbers.json and found this:
"percentFormats-numberSystem-latn": {
"standard": "#,##,##0%"
},
"currencyFormats-numberSystem-latn": {
"currencySpacing": {
"beforeCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
},
"afterCurrency": {
"currencyMatch": "[:^S:]",
"surroundingMatch": "[:digit:]",
"insertBetween": " "
}
},
"standard": "¤ #,##,##0.00",
"accounting": "¤#,##0.00;(¤#,##0.00)",
I also went to CLDR website and dug up what i believe is the format file (en-IN.xml) and found this:
<rulesetGrouping type="OrdinalRules">
<ruleset type="digits-ordinal">
<rbnfrule value="-x">−→→;</rbnfrule>
<rbnfrule value="0">=#,##0=$(ordinal,one{st}two{nd}few{rd}other{th})$;</rbnfrule>
</ruleset>
</rulesetGrouping>
Both of these support the results we are getting are correct and our assumptions on what we expect are wrong. However, if you look out on the internet there are many reputable sites that say our assumptions are correct and the results are incorrect.
This leaves me in a state of not knowing what to do. Who's right? Can you help us to answer this question?
Also, is there a way to "overwrite" the default format if for whatever reason we wanted to change it?
You should use
en-IN
for English as spoken in India, i.e.,Globalize('en-IN')
.