DEV Community

Discussion on: Translating Integers Into An English String in Ruby

Collapse
 
jakebman profile image
jakebman

English is just an instance of a language.

Languages have different ways of doing this.

For instance, there's no seventy in French. The seventies are written as sixty and thirteen.

Then you realize that's why libraries exist and find one that suits your needs.

Collapse
 
jennifer profile image
Jennifer Konikowski

Yes. But this is just an exercise for fun?

Collapse
 
databasesponge profile image
MetaDave 🇪🇺

And a damn good exercise it is too.

We needed to translate integers from 0 to 100 into words for our system, and looked at a few gems, and thought about the logic, and then said "f*ck it" and just created a YAML file:

0: zero
1: one
2: two
...

Problem solved, and testing was pretty straightforward too!

Thread Thread
 
jennifer profile image
Jennifer Konikowski

I love it. Sometimes, if you have a limit like that, writing it out manually can be easier on a quick deadline! Especially if you need to support many languages.