Vote #77334
完了Support of default Active Record (I18n) transliteration paths
0%
説明
For now, in 10-patches.rb we have a redefinition of method human_attribute_name. But default (plain without hierarchy) Redmine style of transliterations are not convinient for some reasons, especially in big projects. So, my proposal is follows: enable ActiveRecord behaviour for finding transliterations path and add in list of search paths custom one from Redmine. Here is a worked snippet of code:
def self.human_attribute_name(attr, options = {})
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
redmine_default =
[
:"field_#{name.underscore.gsub('/', '_')}_#{prepared_attr}",
:"field_#{prepared_attr}"
]
if options[:default].present?
options[:default] = [options[:default]] unless options[:default].is_a? Array
options[:default].unshift redmine_default
else
options[:default] = redmine_default
end
super
end
In this case we obtain follows chain of search paths:
default AR paths (for example: activerecord.attributes.model_name.field_name)¶
default Redmine paths (for example: field_content)¶
user specified paths (specified in :default key from options attribute)¶
@attribute.humanize@ (from default human_attribute_name from ActiveModel)¶
journals
--------------------------------------------------------------------------------
Change committed, thanks.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
related_issues
relates,Closed,26618,Support of default ActiveRecord I18n scopes in LabelledFormBuilder