プロジェクト

全般

プロフィール

Vote #77334

完了

Support of default Active Record (I18n) transliteration paths

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
I18n_37
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
37
version_id:
110
issue_org_id:
22383
author_id:
128697
assigned_to_id:
1
comments:
4
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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

Admin Redmine さんが3年以上前に更新

  • カテゴリI18n_37 にセット
  • 対象バージョン3.3.0_110 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0