I have the below setup
class BudgetLine < ApplicationRecord has_many :budget_line_items accepts_nested_attributes_for :budget_line_itemsendclass BudgetLine::Accommodation < BudgetLineendclass BudgetLineItem < ApplicationRecord belongs_to :budget_lineend
Now I'm trying to specify labels for the nested form of BudgetLineItem
inside BudgetLine
. According to the i18n documentation, you can normally do something like this:
en: activerecord: attributes: user/role: admin: "Admin" contributor: "Contributor"
This works if the model in question is not namespaced, as with User above. However, when you want to specify a namespaced model it has the same syntax, so it becomes:
en: activerecord: attributes: budget_line/accommodation/budget_line_items: unit: Room
which does not work.
I've tried different variations of this, e.g.
en: activerecord: attributes: budget_line: accommodation/budget_line_items: price: Price (USD)
which also does not work, because this way of specifying namespaces in locales seems to be deprecated.
As far as I understand, for the label to be translated correctly, the following should return the correct translation: BudgetLine::Accommodation.human_attribute_name("budget_line_items.unit")
, but so far I've been unsuccessful in my attempts to target this.
Is there a way to solve for this use case?