Multilingual Number To Word Converter - jQuery SpellingNumber

Multilingual Number To Word Converter - jQuery SpellingNumber
File Size: 14.5 KB
Views Total: 77
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

SpellingNumber is a jQuery based multilingual number to word converter that helps convert any numbers (such as Currency, Weight, Length, ...) to words equivalent.

See Also:

Supported Languages:

  • English (en)
  • Portuguese (Brazil) (pt)
  • Portuguese (Portugal) (ptPT)
  • Spanish (es)
  • French (fr)
  • Esperanto (eo)
  • Vietnamese (vi)
  • Arabic (ar)
  • Azerbaijan (az)
  • Turkish (tr)
  • English (Indian) (enIndian)
  • Ukrainian (uk)
  • Indonesian (id)
  • Russian (ru)

How to use it:

1. Load the main script jquerySpellingNumber.js after jQuery library.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/jquerySpellingNumber.js"></script>

2. Convert numbers (Integers or floats) to English words:

$.spellingNumber(1625444.13);
// => One Million Six Hundred Twenty-Five Thousand Four Hundred And Forty-Four Point One Hundred Thirty 

3. Determine which language the converter should use. Default: 'en'.

$.spellingNumber(12300.23, {
  lang: "ar"
});
// => إثنا عشر ألف وثلاثمائة ليرة لبنانية و مائتان وثلاثون قرش

4. Determine whether to use a separator instead of 'and'. Default: false.

$.spellingNumber(12300.23, {
  noAnd: true
});

5. Customize the wholes & fraction units. Default: empty.

$.spellingNumber(12300.23, {
  wholesUnit: "dollars",
  fractionUnit: "cents",
  digitsLengthW2F: 2,
  decimalSeperator: "and"
});
// => Twelve Thousand Three Hundred Dollars And Twenty-Three Cents

6. Config the default languages or create a new one.

$.spellingNumber(12300.23, {
  i18n: {
    'en': {
      "useLongScale": false,
      "baseSeparator": "-",
      "unitSeparator": "and ",
      "decimalSeperator": 'and ',
      "base": {
        "0": "zero",
        "1": "one",
        "2": "two",
        "3": "three",
        "4": "four",
        "5": "five",
        "6": "six",
        "7": "seven",
        "8": "eight",
        "9": "nine",
        "10": "ten",
        "11": "eleven",
        "12": "twelve",
        "13": "thirteen",
        "14": "fourteen",
        "15": "fifteen",
        "16": "sixteen",
        "17": "seventeen",
        "18": "eighteen",
        "19": "nineteen",
        "20": "twenty",
        "30": "thirty",
        "40": "forty",
        "50": "fifty",
        "60": "sixty",
        "70": "seventy",
        "80": "eighty",
        "90": "ninety"
      },
      "units": [
        "hundred",
        "thousand",
        "million",
        "billion",
        "trillion",
        "quadrillion",
        "quintillion",
        "sextillion",
        "septillion",
        "octillion",
        "nonillion",
        "decillion",
        "undecillion",
        "duodecillion",
        "tredecillion",
        "quattuordecillion",
        "quindecillion"
      ],
      "unitExceptions": []
    },
    'eo':{
      "useLongScale": false,
      "baseSeparator": " ",
      "unitSeparator": "",
      "base": {
        "0": "nulo",
        "1": "unu",
        "2": "du",
        "3": "tri",
        "4": "kvar",
        "5": "kvin",
        "6": "ses",
        "7": "sep",
        "8": "ok",
        "9": "naŭ",
        "10": "dek",
        "20": "dudek",
        "30": "tridek",
        "40": "kvardek",
        "50": "kvindek",
        "60": "sesdek",
        "70": "sepdek",
        "80": "okdek",
        "90": "naŭdek",
        "100": "cent",
        "200": "ducent",
        "300": "tricent",
        "400": "kvarcent",
        "500": "kvincent",
        "600": "sescent",
        "700": "sepcent",
        "800": "okcent",
        "900": "naŭcent"
      },
      "units": [
        {
          "useBaseInstead": true,
          "useBaseException": []
        },
        {
          "singular": "mil",
          "avoidPrefixException": [1]
        },
        {
          "singular": "miliono",
          "plural": "milionoj",
          "avoidPrefixException": [1]
        },
        {
          "singular": "miliardo",
          "plural": "miliardoj",
          "avoidPrefixException": [1]
        },
        {
          "singular": "biliono",
          "plural": "bilionoj",
          "avoidPrefixException": [1]
        }
      ],
      "unitExceptions": []
    }, 
    'es':{
      "useLongScale": true,
      "baseSeparator": " y ",
      "unitSeparator": "",
      "base": {
        "0": "cero",
        "1": "uno",
        "2": "dos",
        "3": "tres",
        "4": "cuatro",
        "5": "cinco",
        "6": "seis",
        "7": "siete",
        "8": "ocho",
        "9": "nueve",
        "10": "diez",
        "11": "once",
        "12": "doce",
        "13": "trece",
        "14": "catorce",
        "15": "quince",
        "16": "dieciséis",
        "17": "diecisiete",
        "18": "dieciocho",
        "19": "diecinueve",
        "20": "veinte",
        "21": "veintiuno",
        "22": "veintidós",
        "23": "veintitrés",
        "24": "veinticuatro",
        "25": "veinticinco",
        "26": "veintiséis",
        "27": "veintisiete",
        "28": "veintiocho",
        "29": "veintinueve",
        "30": "treinta",
        "40": "cuarenta",
        "50": "cincuenta",
        "60": "sesenta",
        "70": "setenta",
        "80": "ochenta",
        "90": "noventa",
        "100": "cien",
        "200": "doscientos",
        "300": "trescientos",
        "400": "cuatrocientos",
        "500": "quinientos",
        "600": "seiscientos",
        "700": "setecientos",
        "800": "ochocientos",
        "900": "novecientos",
        "1000": "mil"
      },
      "unitExceptions": {
        "1000000": "un millón",
        "1000000000000": "un billón",
        "1000000000000000000": "un trillón",
        "1000000000000000000000000": "un cuatrillones",
        "1000000000000000000000000000000": "un quintillón",
        "1000000000000000000000000000000000000": "un sextillón",
        "1000000000000000000000000000000000000000000": "un septillón",
        "1000000000000000000000000000000000000000000000000": "un octillón",
        "1000000000000000000000000000000000000000000000000000000": "un nonillón",
        "1000000000000000000000000000000000000000000000000000000000000": "un decillón",
        "1000000000000000000000000000000000000000000000000000000000000000000": "un undecillón",
        "1000000000000000000000000000000000000000000000000000000000000000000000000": "un duodecillón",
        "1000000000000000000000000000000000000000000000000000000000000000000000000000000": "un tredecillón",
        "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000": "un cuatordecillón",
        "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000": "un quindecillón"
      },
      "units": [
        {
          "singular": "ciento",
          "useBaseInstead": true,
          "useBaseException": [1]
        },
        {
          "singular": "mil",
          "avoidPrefixException": [1]
        },
        {
          "singular": "millón",
          "plural": "millones"
        },
        {
          "singular": "billón",
          "plural": "billones"
        },
        {
          "singular": "trillón",
          "plural": "trillones"
        },
        {
          "singular": "cuatrillón",
          "plural": "cuatrillones"
        },
        {
          "singular": "quintillón",
          "plural": "quintillones"
        },
        {
          "singular": "sextillón",
          "plural": "sextillones"
        },
        {
          "singular": "septillón",
          "plural": "septillones"
        },
        {
          "singular": "octillón",
          "plural": "octillones"
        },
        {
          "singular": "nonillón",
          "plural": "nonillones"
        },
        {
          "singular": "decillón",
          "plural": "decillones"
        },
        {
          "singular": "undecillón",
          "plural": "undecillones"
        },
        {
          "singular": "duodecillón",
          "plural": "duodecillones"
        },
        {
          "singular": "tredecillón",
          "plural": "tredecillones"
        },
        {
          "singular": "cuatrodecillón",
          "plural": "cuatrodecillones"
        },
        {
          "singular": "quindecillón",
          "plural": "quindecillones"
        }
      ]
    },
  }
});

This awesome jQuery plugin is developed by mattar88. For more Advanced Usages, please check the demo page or visit the official website.