0

I have a file that is located: app/controllers/api/v1/users/searches_controller.rb

This file starts as following:

module Api
  module V1
    module Users
      class SearchesController < ActionController::API

And I have this code:

I18n.t('.search')

When I say

i18n-tasks missing

It wants to put my key like thins: .search

Which is not in the way I would like which is

api:
  v1:
    users:
      searches_controller:
      .......

When I say:

t('.search')

I get an error with: NoMethodError - undefined methodt' for ....`

But i18n-tasks missing gives me the keys as following:

api:
    v1:
      users:
        searches:
          users_with_email_or_username:
          .......

Am I doing something wrong or?

  • I'm not sure it's your problem but, if you're using the `t` shortcut, without I18n before, it should be `t('.seach')` instead of `.t('.search')` (remove the dot). With the dot, rails tries to apply the `t` method to nothing and throws an error – cercxtrova Apr 12 '19 at 13:46
  • @escanxr that would be a `SyntaxError` though. OP what is the actual issue? To use lazy lookup you have to follow convention which would be `searches` not `searches_controller` if you want to use a full lookup then you should be fine `I18n.t('api.v1.users.searches_controller.[whatever]')` – engineersmnky Apr 12 '19 at 14:07
  • @escanxr Yes, the dot is a mistake, the call is `t('search') @engineersmnky Yes, I would like searches, not searches controller, but this is what I18n-tasks gives me, when I use `i18n-tasks missing` – Mihail hidr0 Kirilov Apr 14 '19 at 10:28

0 Answers0