Closed Sagarmak-zz closed 7 years ago
Thank for reporting an issue! Do you consider this a bug or a feature request? As of the lates release, (as stated in the readme) only integers are supported. If you consider this a bug, please provide some more info and/or test cases. If this is a feature request, can you please provide some input data and expected output?
Thanks for the reply @marlun78. In my invoice generation system(beta), I need to print the amount in numeric as well in words. As the variables have the value with comma, say 17,478, it states as seventeen. Works perfectly fine without comma.
(I'm assuming the above example is seventeen thousand four hundred and seventy-eight not seventeen point four hundred and seventy-eight...
Different countries uses different decimal and thousands delimiters. Consider the following input; 1,234.56 (US) 1.234,56 (DK) 1 234,56 (SE) Without the culture info, there is no way to know how to parse these numbers correctly. For this reason, you'll have to clean up before passing it to the translator function. I hope this help!?
Hello @marlun78 sorry for interrupting between the conversation, Here you didn't understood the use case given by @Sagarmak here is the brief explanation of the use case given by @Sagarmak -- Take one number - 17,330 - originally it should return me 'seventeen thousand three hundred thirty' but here it is returning me only 'seventeen'. reason of such behavior there is COMMA (,) in between is used as a formatting, not POINT(.)
I would consider it as a bug because most of the time separator are used in bills and other place where money is involved
ATM, decimals are currently not supported and it is clearly stated in the README file:
toWords(number) Converts an integer into words. If number is decimal, the decimals will be removed.
toWords
is internally using parseInt
to get a Number value from the input (Number or String). So you can pass either '17,444'
or '17.444'
and the result will be the same; 'seventeen'
. If what you want is for it to be handled as 17444
, you’ll have to do the parsing/cleanup before passing it to toWords
.
In upcoming release can we expect such this kind of use case working ? @marlun78
comma separated numbers has only the part before the first coma. What is the solution here..?