Reputation: 555
I'd like to pluralize a translation with words for the numbers instead of numerals.
So, for example, I'd like to be able to have a translation that results in:
"The Patriots came back to win the Superbowl by scoring thirty-one points in a row."
...instead of:
"The Patriots came back to win the Superbowl by scoring 31 points in a row."
Is there a way to do this?
Upvotes: 0
Views: 272
Reputation: 4413
I think what you're looking for is humanize:
2.humanize # => "two"
4.humanize # => "four"
8.humanize # => "eight"
Or in your case:
str = "The Patriots came back to win the Superbowl by scoring 31 points in a row."
humanized = str.gsub(/\d+/) do |match|
match.to_i.humanize
end
humanized # => "The Patriots came back to win the Superbowl by scoring thirty-one points in a row."
Upvotes: 4