Operations inside Rails I18n locales' strings

Posted by Cristobal Viedma on Stack Overflow See other posts from Stack Overflow or by Cristobal Viedma
Published on 2010-12-23T10:16:14Z Indexed on 2010/12/23 10:54 UTC
Read the original article Hit count: 198

Hi, I am trying to put operations inside the locales to adapt to different languages. For example, in English a billion is 1,000,000,000, however in Spanish a billion is 1,000,000,000,000 so I would like to be able to have the following:

en:
  billion: "You have %{money} billions"
es:
  billion: "Tienes %{money/1000.0} billones"

In order to be able to write:

I18n.t :billion, :money => whatever

And be right for whatever language.

However, it seems that I cannot put operations inside the locales' strings.

Any hint on how should I be doing this? Maybe my approach is just wrong "philosophically" talking?

Thanks all!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby