Krokus
A provider for localization patterns and a number and currency formatter and parser.
In order to have the all currency and locale patterns in one place.
ISO 4217 is a standard to format currencies.
The data is generated from CLDR33.
Installation
npm install --save-dev krokus
Use the krokus formatter
; const formatPattern = pattern: '#,##0.00 ¤' decimal_sep: ',' group_sep: '.' symbol: '€'; > krokus;1000000 €
Use the krokus parser
; const formatPattern = pattern: '#,##0.00 ¤' decimal_sep: ',' group_sep: '.' symbol: '€'; > krokus;10000
Access the generated currency and locale settings
; > krokuslocalesde_DE decimal_sep: ',' group_sep: '.' number_pattern: '#,##0.###' currency_pattern: '#,##0.00 ¤' > krokuscurrenciesEUR symbol: '€' wideSymbol: '€' code: 'EUR'
Real-life example
Use the krokus calls in your functions:
; const formatNumber = { const format = krokuslocaleslocale; formatpattern = formatnumber_pattern; return krokus;}; const formatCurrency = { if !currency return ; const localeData = krokuslocaleslocale; const currencyData = krokuscurrenciescurrencycode; return krokus;};
Run the tests if the formats are still generating the expected formatted numbers in JS
npm install
npm test
Generate the krokus number formatter from the es6 files
npm install
npm run compile
Create the up-to-date version of the json files
bundle install
rake update