Number as Words

Events happening in the community are now at Drupal community events on www.drupal.org.
acushla's picture

Hi,

I have written a module that adds a cck number field formatter that shows the number in words.

Ex. 123456 is shown as One Hundred and Twenty-Three Thousand Four Hundred and Fifty-Six.

Do you think it will be a good idea to contribute this module?

Thanks in advance,
Rajat

Comments

Old code I made

mikeytown2's picture

Here's an old issue I made in regards to this
http://drupal.org/node/331700#comment-1179255

Got the core logic from here
http://www.roscripts.com/snippets/show/53

I would say contribute it but look into including other formatters as well

I'd find it useful. But it

no2e's picture

I'd find it useful.

But it should be possible to display both, the number and the number in words. Like:
123456 (One Hundred and Twenty-Three Thousand Four Hundred and Fifty-Six)

Thanks so much

acushla's picture

Thanks so much Mike and no2e. :-)
Looking forward to contribute the module with configuration option to include no2e's suggestion.

One Hundred and Twenty-Three

Garrett Albright's picture

One Hundred and Twenty-Three Thousand Four Hundred and Fifty-Six

English major alert! Technically speaking, both of the "and"s in this are incorrect. "And" should only be used to separate the fraction part of the number (if any) from the whole number. So both of these would be correct:

One hundred twenty-three thousand four hundred fifty-six

One hundred twenty-three thousand four hundred fifty-six and seven eighths

But either way, though a module like this could be nifty, I think it would only really be practical on smaller numbers than this. "123,456" is much easier to read than "One hundred twenty-three thousand four hundred fifty-six."

US English or UK English?

fonant's picture

The "and"s are correct, and expected, in UK English, as opposed to American English :)

We would say "One hundred and twenty-three thousand, four hundred and fifty-six" here. We think that the American way of omitting the "and"s sounds very odd ;)

We'd probably say "One hundred and twenty-three thousand, four hundred and fifty-six, and seven eighths" too, although this sort of number is very unlikely to appear in real life.

Huh. I did not learn that as

Garrett Albright's picture

Huh. I did not learn that as a difference of American English, but it appears you're correct. What do you know.

Utilize what is there.

zzolo's picture

Just a side note. IMO, this should just be a formatter for the existing number field that comes with CCK. (assuming it already not)

--
zzolo

Just what I am looking for

ChrisRut's picture

This is what I am looking for, I agree with zzolo, this should be added to the CCK number field as a display format.
Just my $0.02
-Chris

shows the number in words.

kemotion's picture

Acushla, As I can access the module you developed? I would like to try.

the solution

diriy's picture

I need to show the price, provided by drupal commerce, in separate field or block, converted into words. How can I do it?

Anybody interested may

prakashsingh's picture

Anybody interested may checkout this one.

https://www.drupal.org/project/number2word

here is another d8/d9 release

pbhuktar7's picture

here is another d8/d9 release for the Number as Words
https://www.drupal.org/project/twig_n2w

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: