Created
July 13, 2020 13:45
-
-
Save Lunberg88/3a88b4f4c103eafaac739fb960181577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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