Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass arguments in I18n.translate

I18n.translate can translate error.messages like this:

I18n.translate('error.messages.taken')
-> has already been taken

But there are some error messages that contains arguments like:

I18n.translate('error.messages.greater_than_or_equal_to')
-> must be greater than or equal to %{count}"

Is it possible to pass the argument ‘count’ in the I18n.translate?

like image 395
Leo Avatar asked Sep 07 '16 12:09

Leo


1 Answers

You can pass the params after the key

I18n.translate('error.messages.greater_than_or_equal_to', count: 2)
like image 142
Deepak Mahakale Avatar answered Sep 22 '22 19:09

Deepak Mahakale