1

I have been reading the Intl API - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

And it is awesome. I plan to start using it extensively.

However there is one thing I am looking for. I want to convert "3" to "three". Numeric to string. Based on the locale. Is this possible?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • 1
    Looks like your API only formats number, but does not converts number to it's word-expression. If it's finite amount of numbers and relatively small subset, you can try to map value to word – Justinas Dec 15 '16 at 12:16
  • 1
    If the question regards a built in function then no, there is none yet. – Lain Dec 15 '16 at 12:17
  • Thank you both. I needed to support many languages, not just english. Similar style to how Intl does it with currency, dates, etc. – Noitidart Dec 15 '16 at 12:18
  • 1
    Since not all languages are even mapping the 'written' numbers from left to right like english does, it might be a difficult task. – Lain Dec 15 '16 at 12:19
  • Thanks @Lain I will try to find a library out there that does this. – Noitidart Dec 15 '16 at 12:22
  • @Noitidart I use the Humanizer library for this sort of thing. It has international support (though I admit I've only ever used it for English). It's a .Net library, but a JS port exists. –  Jul 03 '17 at 17:15
  • 1
    Some languages do not have words for numbers, just words like "few" and "many". Some languages may decline numbers--in some cases giving the same number more than a dozen forms depending on the gender of what is being counted, etc. Japanese has counters, so to say "two(boats)" you have to use the boat counter, but to say "two (pencils)" you have to use the counter for long narrow things. –  Jul 03 '17 at 17:25
  • Wow @torazaburo thank you for that insight! It is very interesting!! – Noitidart Jul 03 '17 at 20:05

0 Answers0