for instance, my designer wants a capital 'M' for millions v lowercase 'm',
i see i could overwrite my entire locale spec, but i was hoping for a more terse way,
something like:
numeral.language().override({abbreviations: {million: 'M'}})
or i could use underscore/lodash extend() or default() against the abbreviation object if there was a method to return it, but right now it looks like numeral.language() just returns the string name of the language...
regards,
tony.
You can do
e.language("en", {
delimiters: {
thousands: ",",
decimal: "."
},
abbreviations: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T",
},
ordinal: function(e) {
var t = e % 10;
return~~ (e % 100 / 10) === 1 ? "th" : t === 1 ? "st" : t === 2 ? "nd" : t === 3 ? "rd" : "th"
},
currency: {
symbol: "$"
}
});
I came with the same question -- on the numeral home page, I can run numeral.languageData() and get back the object configuring the language. Then I could make my change and away we go -- but it doesn't seem possible with the version on CDN.
In other words, I think we want to be able to tweak the abbreviation without having to tweak anything else. Seems simple but not possible?
@cymen you should be able to using the CDN version as it shouldn't be any different then having the JS loaded locally.
You can modify the object that's returned from numeral.languageData() using underscore/lodash to change just the abbreviations or do as @wopian showed to overwrite everything.
_.assign(numeral.languageData('en'), {
abbreviations: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T"
}
});
In my case, I didn't want abbreviations enabled so I null them out:
_.assign(numeral.languageData(), { abbreviations: {} })
It is currently numeral.localeData('en').
In chinese culture, we don't use thousands as a delimiter, but in 10k, as a '1万'.
Is there any way to make a custom 4 digit per delimiter local config?
i disabled abbreviations and currencies by adding following two line after setting up locale for numeral
numeral.localeData().abbreviations = {};
numeral.localeData().currency = {};
Most helpful comment
In chinese culture, we don't use thousands as a delimiter, but in 10k, as a '1万'.
Is there any way to make a custom 4 digit per delimiter local config?