joh*_*ohm 7 ruby ruby-on-rails internationalization ruby-on-rails-4
我在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"
Run Code Online (Sandbox Code Playgroud)
在我的模型中,我有这个:
has_many :entities, dependent: :restrict_with_error
Run Code Online (Sandbox Code Playgroud)
每当触发restrict_dependent_destroy时,%{record}将以英语显示模型名称(复数),并且不会被翻译,如下所示:"Nãoépossívelsexluiro registro pois existem entities dependdentes".
我有另一个文件,其中包含:entities的翻译
br:
activerecord:
models:
entities: 'entidades'
Run Code Online (Sandbox Code Playgroud)
rails在哪里获得%{record}的翻译?我在这里错过了什么吗?
提前致谢!
这是: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'
Run Code Online (Sandbox Code Playgroud)