Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource names are not being translated properly on notice messages #1242

Closed
rscardinho opened this issue Nov 27, 2018 · 1 comment · Fixed by #1626
Closed

Resource names are not being translated properly on notice messages #1242

rscardinho opened this issue Nov 27, 2018 · 1 comment · Fixed by #1626
Labels
bug breakages in functionality that is implemented i18n translations and language support

Comments

@rscardinho
Copy link

rscardinho commented Nov 27, 2018

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

@rscardinho
Copy link
Author

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

@nickcharlton nickcharlton added bug breakages in functionality that is implemented i18n translations and language support labels Jan 2, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
betelgeuse added a commit to betelgeuse/administrate that referenced this issue Apr 28, 2020
nickcharlton pushed a commit to betelgeuse/administrate that referenced this issue Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented i18n translations and language support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants