Languages
Supported languages and how to change the language to use.
Include
To benefit from multiple languages support, you only need to include the languages.js
file. As for the main file, it comes with many flavors.
cdnjs
<script src="//cdnjs.cloudflare.com/ajax/libs/numbro//min/languages.min.js"></script>
Bower
<script src="./bower_components/numbro/dist/min/languages.min.js"></script>
Node.js
<script src="./node_modules/numbro/dist/min/numbro.min.js"></script>
GitHub
<script src="./numbro/dist/min/numbro.min.js"></script>
Supported languages
The supported languages and cultures a registered following the Microsoft's Culture Names.
Culture | Code |
---|
Define a new language
You can easily define your own language if you can find what you want in the list of supported languages.
// define a language
numbro.language('fr-BE', {
delimiters: {
thousands: ' ',
decimal: ','
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal : function (number) {
return number === 1 ? 'er' : 'ème';
},
currency: {
symbol: '€',
position: 'postfix'
},
defaults: {
currencyFormat: ',0000 a'
},
formats: {
fourDigits: '0000 a',
fullWithTwoDecimals: ',0.00 $',
fullWithTwoDecimalsNoCurrency: ',0.00',
fullWithNoDecimals: ',0 $'
}
});
Change language
To change the language to use, you only need to use the language
function with the culture code of the language needed.
// switch between languages
numbro.language('fr-BE');