Hi,
I wanted these 10M not 10m and 10K not 10k. Is there a way for this?
would like to know this as well. good question!
ok this is working for me---hope it works for you!
var numeral = require('numeral');
numeral.register('locale', 'us', {
delimiters: {
thousands: ' ',
decimal: '.'
},
abbreviations: {
thousand: 'K',
million: 'M',
billion: 'B',
trillion: 'T'
},
ordinal : function (number) {
return number === 1 ? 'er' : '猫me';
},
currency: {
symbol: '$'
}
});
// switch between locales
numeral.locale('us');
So, we will need to re-write our locale files? I wanted a way to change the abbreviations out of the box actually. I will make a PR for this if there is no way other than this.
I'd propose changing this through the .format function like the followings:-
.format('0.0a) (a) for small letters and .format('0.0A') (A) for capital letters.What do you think?
Be careful. 10M means 10 million where 10m means mili. They are not same. https://en.wikipedia.org/wiki/Metric_prefix#List_of_SI_prefixes
I did this for vuejs app, it may help.
Vue.filter('capitalize', function (string) {
var capitalFirst = string.toUpperCase()
return capitalFirst
})
For the display
{{ total_count | numeral('0,0 a') | capitalize }}
So did this ever get fixed or just closed? @NouranMahmoud
Just closed. @de-ocampo
This is not necessary. You only need to add uppercase css
<span class="uppercase">{{ numeral(50000).format('0a) }}</span>
<style>
.uppercase { text-transform: uppercase; }
</style>
As pointed out by @khan4019 this is a convention problem.
While easy to fix in css, I feel like this should be OOB in the library as it is breaking existing international conventions.
An easy fix would be defaulting to the convention rather than displaying everything lowercase.
Most helpful comment
So, we will need to re-write our locale files? I wanted a way to change the abbreviations out of the box actually. I will make a PR for this if there is no way other than this.
I'd propose changing this through the
.formatfunction like the followings:-.format('0.0a)(a) for small letters and.format('0.0A')(A) for capital letters.What do you think?