Skip to content

Instantly share code, notes, and snippets.

@Lunberg88
Created July 13, 2020 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lunberg88/3a88b4f4c103eafaac739fb960181577 to your computer and use it in GitHub Desktop.
Save Lunberg88/3a88b4f4c103eafaac739fb960181577 to your computer and use it in GitHub Desktop.
// numeralLocale.js
//
import numeral from 'numeral';
let locales = {
'en': {
delimiters: {
decimal: '.',
thousands: ','
},
abbreviations: {
billion: 'b',
million: 'm',
thousand: 'k',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: '$'
}
},
'de-ch': {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: 'CHF'
}
},
'de': {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: 'EUR'
}
},
'fr': {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: 'EUR'
}
},
'it': {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
return '.';
},
currency: {
symbol: 'EUR'
}
}
};
export const register = (currency) => {
console.log('Numeral #1', numeral.locales);
Object.keys(locales).forEach(localeName => {
console.log(localeName)
numeral.register('locale', localeName, {
...locales[localeName],
currency: {
symbol: currency
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment