将默认值应用于命名空间的 ActiveRecord 翻译

Apply defaults to namespaced ActiveRecord translations

我有一些带有价格属性的模型,我想翻译。

在我的语言环境文件中,我有这样的翻译:

de:
  activerecord:
    attributes:
      defaults:
        price: Preis

这适用于任何非命名空间模型,例如:

Shoe.human_attribute_name(:price) # works!

但是,它不适用于命名空间模型,例如:

Product::Shoe.human_attribute_name(:price) # doesn't translate!

是否可以保持翻译文件干燥并将默认值也应用于命名空间模型?

您可以像这样在您的 i18n 文件中添加 namespace/model

de:
  activerecord:
    attributes:
      product/shoe:
        price: Preis