Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I18n for flash messages with parameters in Rails

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."      
like image 480
valk Avatar asked Sep 16 '13 08:09

valk


1 Answers

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."      
like image 187
Rajesh Kolappakam Avatar answered Oct 13 '22 00:10

Rajesh Kolappakam