Domanda

How can I add parameters to my parametrized and internationalized error message? Say, in my controller there's:

flash[:error] = t(:error)[:my_error_message] 

And in en.yml:

error:
  my_error_message: "This is the problem XXX already."      
È stato utile?

Soluzione

For your flash message,

flash[:error] = t('my_error_message', :problem => 'Big Problem')

In your en.yml:

error:
  my_error_message: "This is the problem %{problem} already."      

Altri suggerimenti

t('error.my_error_message')

or:

t(:my_error_message, scope: :error)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top