我在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"
在我的模型中,我有这个:
has_many :entities, dependent: :restrict_with_error
每当触发restrict_dependent_destroy时,%{record}显示的是英文版的模型名称(复数),并且没有被翻译,如下所示:“Nãoépossívelsexluiro registro pois existem entities dependdentes”。
我有另一个包含以下内容的文件:entities
br:
activerecord:
models:
entities: 'entidades'
rails在哪里获得%{record}的翻译?我在这里错过了什么吗?
提前致谢!
答案 0 :(得分:4)
这是:restrict_with_error
消息(https://github.com/rails/rails/pull/10787)中的错误。
作为一种解决方法,您可以使用:
br:
activerecord:
attributes:
entity: # Should be the parent class when bug https://github.com/rails/rails/pull/10787 is fixed
entities: 'entidades'