views:

50

answers:

1

Hi, I am using I18n internationnalization plugin, but it's not translating 1 piece of information :

In one of my controller, I have a verify method like this :

  # Verify user is authenticated
  verify :only => [ :destroy, :create, :update, :new, :comment ],
     :session => :user_id,
     :add_flash => { :error => I18n.t(:'Exceptions.not_logged_in') },
     :redirect_to => { :controller => 'main' , :action => 'index' }

However, using I18n.t(:'Exceptions.not_logged_in') always display the default_locale, in this case, english.

I have in my Application_Controller a before_filter that sets the locale.

Can anybody help me understand, and help me find a workaround?

Thanks!

P.S.: I tried adding a call to set_locale before this verification method without success (in my controller)

A: 

I think it might have something to do with that I18n.t call being run only once when the file is initially loaded on app startup. You could try wrapping it in a Proc or lambda or maybe in a separate method. e.g. something like:

:add_flash => lambda { { :error => I18n.t(:'Exceptions.not_logged_in') } }

No idea if that'll work, but it might get you closer.

eremite
Good idea, but it seems its refusing having a Proc in there. Error msg is "no marshal_dump is defined for class Proc"