Administrate: Resource names are not being translated properly on notice messages

Created on 27 Nov 2018  路  1Comment  路  Source: thoughtbot/administrate

The resource model name isn't being translated when you execute a DB transaction (create, for example). The whole message is translated according to the yml file but the resource model name.

I believe the problem relies on ResourceReolver#resource_title, which just parses the current path and returns a joined string. The #translate_with_resource (the method that translated the message itself) should use ResourceReolver#resource_class combined with ActiveRecord locale methods to return the resource model name already localized to the message _translator_ method

This is the message that I'm getting
image

And my yml file does have that model translation entry

pt-BR:
  activerecord:
    models:
      transaction_category:
        one: 'Natureza de Transa莽茫o'
        other: 'Naturezas de Transa莽茫o'

This problem is happening with other resources around my admin section

bug i18n

Most helpful comment

I've worked around this by overriding the #translate_With_resource method on my Admin::ApplicationController with the following

def translate_with_resource(key)
  t(
    "administrate.controller.#{key}",
    resource: resource_class.model_name.human
  )
end

But I still think that this should come by default

>All comments

I've worked around this by overriding the #translate_With_resource method on my Admin::ApplicationController with the following

def translate_with_resource(key)
  t(
    "administrate.controller.#{key}",
    resource: resource_class.model_name.human
  )
end

But I still think that this should come by default

Was this page helpful?
0 / 5 - 0 ratings