Forum: Rails I18n localize and lambdas

Posted by rob-twf (Guest)
on 2010-04-06 22:50
(Received via mailing list)
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
Posted by Lucas de Castro (Guest)
on 2010-05-03 07:34
(Received via mailing list)
Hi Rob,

Some weeks ago I opened an issue about this in GitHub:
http://github.com/svenfuchs/i18n/issues/issue/14
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/...
http://github.com/svenfuchs/i18n/blob/master/test/...
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
Posted by rob-twf (Guest)
on 2010-05-21 16:16
(Received via mailing list)
Thanks for the reply Lucas, looks like your fix has made it into the
official code now too!

Rob
Posted by Lucas de Castro (Guest)
on 2010-05-21 16:24
(Received via mailing list)
Yes Rob, it is there! :)

On Fri, May 21, 2010 at 11:15 AM, rob-twf 
<rob.anderton@googlemail.com>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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.