I am looking for JavaScript function to convert numbers to Arabic words
For example
- 23 > ثلاثة وعشرين
- 53 > ثلاثة وخمسون
- .... > ....
I found some solutions but it is all .net
- http://www.codeproject.com/Articles/112949/Number-To-Word-Arabic-Version
- http://libstation.com/products/numbers-in-words/
I have searched the web but could not find any solution ( well, i could not understand while searching in Arabic ;) )
I've written an NPM package for this check: https://github.com/mmahgoub/tafgeetjs
$npm install tafgeetjs
Usage:
var Tafgeet = require('tafgeetjs');
var stringText = new Tafgeet(556563.20, 'SDG').parse();
this will produce: 'فقط خمسمائة وستة وخمسون ألف وخمسمائة وثلاثة وستون جنيه سوداني وعشرون قرش لا غير'.
There is an Angular example too.
This answer is two years late, but...
All the answers to this question assume Arabic number words work the same ways as English ones do. Unfortunately, this is not true. Arabic sentence structure is much, much more complex than English ones, and the words used for numerals vary based on whether what you're counting is a masculine object or a feminine object (objects in Arabic, like in French, have gender), and based on the position of the counted object in the sentence (whether it is the subject, the object, after a preposition, etc).
For masculine objects (مذكر) that are مرفوعين, you can use this snippet that I just wrote because I couldn't find the answer to this question anywhere. It works for numbers less than 1 million, and does not work for what's after the floating point (yet).
It could get more refined than this, but, considering how the rules of the language are not as uniform as English, doing this with a loop (like you would in English) would be very counter-productive in my opinion.
You can do use similar function :
http://jsbin.com/jesoj/1/
Zero to Million :
Zero to one hundred :
Good translate.