Feature #22383

Support of default Active Record (I18n) transliteration paths

Added by Ivan Zabrovskiy almost 2 years ago. Updated over 1 year ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:I18n
Target version:3.3.0
Resolution:Fixed

Description

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:
  1. default AR paths (for example: activerecord.attributes.model_name.field_name)
  2. default Redmine paths (for example: field_content)
  3. user specified paths (specified in :default key from options attribute)
  4. attribute.humanize (from default human_attribute_name from ActiveModel)

Associated revisions

Revision 15330
Added by Jean-Philippe Lang almost 2 years ago

Support of default Active Record (I18n) transliteration paths (#22383).

Patch by Ivan Zabrovskiy.

History

#1 Updated by Jean-Philippe Lang almost 2 years ago

  • Target version set to 3.3.0

#2 Updated by Jean-Philippe Lang almost 2 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Change committed, thanks.

#3 Updated by Toshi MARUYAMA over 1 year ago

  • Description updated (diff)

Also available in: Atom PDF