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/languages.min.js"></script>

GitHub

<script src="./numbro/dist/min/languages.min.js"></script>

Supported languages

The supported languages are registered following the IETF's BCP 47.

Language Tag

Define a new language

You can easily define your own language if you can't find what you want in the list of supported languages.

// define a language
numbro.registerLanguage({
    languageTag: "fr-BE",
	languageName: "French (Belgium)",
    delimiters: {
        thousands: " ",
        decimal: ","
    },
    abbreviations: {
        thousand: "k",
        million: "m",
        billion: "b",
        trillion: "t"
    },
    ordinal: (number) => {
        return number === 1 ? "er" : "ème";
    },
    currency: {
        symbol: "",
        position: "postfix",
        code: "EUR"
    },
    currencyFormat: {
        thousandSeparated: true,
        totalLength: 4,
        spaceSeparated: true,
        average: true
    },
    formats: {
        fourDigits: {
            totalLength: 4,
            spaceSeparated: true,
            average: true
        },
        fullWithTwoDecimals: {
            output: "currency",
            mantissa: 2,
            spaceSeparated: true,
            thousandSeparated: true
        },
        fullWithTwoDecimalsNoCurrency: {
            mantissa: 2,
            thousandSeparated: true
        },
        fullWithNoDecimals: {
            output: "currency",
            spaceSeparated: true,
            thousandSeparated: true,
            mantissa: 0
        }
    }
});
If you lack a language, please help us to improve numbro by submitting a pull request.

Change language

To change the language to use, you only need to use the setLanguage function with the language tag of the language needed.

// switch between languages
numbro.setLanguage('fr-BE');