Internationalization of rails:% {record} not translated

I have this on my rails.pt-BR.yml:

br: errors: format: ! '%{attribute} %{message}' messages: restrict_dependent_destroy: one: "Não é possível excluir o registro pois existe um %{record} dependente" many: "Não é possível excluir o registro pois existem %{record} dependentes" 

In my model, I have this:

 has_many :entities, dependent: :restrict_with_error 

Whenever the restrict_dependent_destroy function is run,% {record} displays the model name (plural) in English and is not translated as follows: "Não é possível excluir o registro pois existem entities dependances".

I have another file containing translation for: entities

 br: activerecord: models: entities: 'entidades' 

Where do the rails get the transfer for% {record}? Did I miss something?

Thanks in advance!

+6
source share
1 answer

This is an error in the message :restrict_with_error ( https://github.com/rails/rails/pull/10787 ).

As a workaround, you can use:

 br: activerecord: attributes: entity: # Should be the parent class when bug https://github.com/rails/rails/pull/10787 is fixed entities: 'entidades' 
+3
source

Source: https://habr.com/ru/post/973227/


All Articles