Localize and lambdas

Since localize was changed to go via translate rather than directly
resolving, it seems lambdas no longer work. The problem being that the
lambda is called in translate, which doesn’t have access to the object
being localized.

Is this a bug? If it isn’t, what’s the suggested way of supporting
lambdas in localization now?

A simple example, which works with 0.3.3 (as bundled with Rails 2.3.5)
but breaks with 0.3.6:

{
:en => {
:date => {
:formats => {
:long_ordinal => lambda { |date, options| “%B
#{date.day.ordinalize}, %Y” }
}
}
}

Thanks in advance,
rob

Hi Rob,

Some weeks ago I opened an issue about this in GitHub:

and today Jose Válim answered and asked me checkout this mailing
list.

So, in test suite this feature was commented:
http://github.com/svenfuchs/i18n/blob/master/test/api/tests/localization/date.rb
http://github.com/svenfuchs/i18n/blob/master/test/api/tests/localization/time.rb
this means the developers know this bug.

While I waited an answer from GitHub I got fixed this bug and I sent a
pull request to Sven Funchs but didn’t get a answer yet.

José Valim, I sent a pull request again addressing you (too). Could
you checkout it? Excuse me for not having sent a message in request, I
sent the form of pull request without want, before fill the message.

Thanks,
Lucas de Castro

Thanks for the reply Lucas, looks like your fix has made it into the
official code now too!

Rob

Yes Rob, it is there! :slight_smile:

On Fri, May 21, 2010 at 11:15 AM, rob-twf
[email protected]wrote:

and today Jose Válim answered and asked me checkout this mailing
José Valim, I sent a pull request again addressing you (too). Could

but breaks with 0.3.6:
}
.
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en.


Lucas