Default I18n scope in controller with Grape

465 views Asked by At

I'm using Grape and I have a controller in directory app/controllers/api/v1/sessions.rb

I am currently using the following command to display messages:

I18n.t('anything', scope: 'api.sessions')

But there is a redundancy, because throughout the file is used the same scope. How can I make it standard? To be able to use something like:

I18n.t('anything')
1

There are 1 answers

0
dax On

why not just write a method?

private

def translate_for(key)
  I18n.t(key, scope: 'api.sessions')
end