Feature #22383

Updated by Toshi MARUYAMA over 5 years ago

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:
<pre><code class="ruby"> &lt;pre&gt;
def self.human_attribute_name(attr, options = {})
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')

redmine_default =
:"field_#{name.underscore.gsub('/', '_')}_#{prepared_attr}",

if options[:default].present?
options[:default] = [options[:default]] unless options[:default].is_a? Array
options[:default].unshift redmine_default
options[:default] = redmine_default

</code></pre> &lt;/pre&gt;

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)