diff options
| author | Alban Peignier | 2018-03-22 17:46:35 +0100 | 
|---|---|---|
| committer | Luc Donnet | 2018-03-23 17:21:56 +0100 | 
| commit | fc684594b6075ce6e35a983e085a777682d505b7 (patch) | |
| tree | 7ef63128c39e304e26663bf58e18c527089cfe7c /config | |
| parent | a4c0a3c90bf08b072af2afafd354b424af87d585 (diff) | |
| download | chouette-core-fc684594b6075ce6e35a983e085a777682d505b7.tar.bz2 | |
Fixe features/vehicle_journey_imports spec. Refs #6296
Diffstat (limited to 'config')
| -rw-r--r-- | config/initializers/i18n.rb | 19 | 
1 files changed, 12 insertions, 7 deletions
diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 02d42f899..5df33ff78 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -113,29 +113,29 @@ class Date    include EnhancedTimeI18n  end -class ActiveRecord::Base +module EnhancedModelI18n    # Human name of the class (plural) -  def self.t opts={} +  def t opts={}      "activerecord.models.#{i18n_key}".t({count: 2}.update(opts))    end    # Human name of the class (singular) -  def self.ts opts={} +  def ts opts={}      self.t({count: 1}.update(opts))    end    # Human name of the class (with comma) -  def self.tc(params={}) +  def tc(params={})      I18n.tc(i18n_key, params)    end    # Human name of the attribute -  def self.tmf(attribute, params={}) +  def tmf(attribute, params={})      I18n.tmf "#{i18n_key}.#{attribute}", params    end    # Translate the given action on the model, with default -  def self.t_action(action, params={}) +  def t_action(action, params={})      key = case action.to_sym      when :create        :new @@ -153,7 +153,12 @@ class ActiveRecord::Base    end    private -  def self.i18n_key +  def i18n_key      model_name.to_s.underscore.gsub('/', '_')    end + +end + +class ActiveRecord::Base +  extend EnhancedModelI18n  end  | 
