I18n.with_options bloc executed TWICE

Hi, to avoid putting the whole locale scope on every I18n.t call I’m
trying to use a scope, as stated in the doc
(Active Support Core Extensions — Ruby on Rails Guides)

I tried with

<%= I18n.with_options :locale => :en, :scope => ‘portal.visitor_menu’ do
|i18n|%>
Try <%= i18n.t :fav_songs %>
<% end %>

But it produce
Try favorite song
Try favorite song

I mean, the bloc is executed TWICE. The same code exercised under the
rails console is executed only ONCE.

Anybody have an idea of this strange phenomenom ?

Thanks

On Oct 1, 1:07 pm, Bob M. [email protected] wrote:

But it produce
Try favorite song
Try favorite song

I mean, the bloc is executed TWICE. The same code exercised under the
rails console is executed only ONCE.

Anybody have an idea of this strange phenomenom ?

You probably want <% for the first tag. Right now the call to i18n.t
is outputting text, and the call to with_options is also a <%= so will
output whatever the result of that evaluation is

Fred