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
(http://guides.rubyonrails.org/active_support_core_extensions.html#with_options)

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs