diff options
| author | Alban Peignier | 2018-03-22 17:46:35 +0100 | 
|---|---|---|
| committer | Alban Peignier | 2018-03-22 17:46:35 +0100 | 
| commit | 9a7aa3c98206f83f70cee67e6f67b289537dd2c0 (patch) | |
| tree | 8177f4b49b1c00ebd45fd30f8973b1572908b01d | |
| parent | 246382fd77799e4cf1a04578be0d8f0e982a5164 (diff) | |
| download | chouette-core-9a7aa3c98206f83f70cee67e6f67b289537dd2c0.tar.bz2 | |
Fixe features/vehicle_journey_imports spec. Refs #6296
| -rw-r--r-- | app/models/vehicle_journey_import.rb | 2 | ||||
| -rw-r--r-- | config/initializers/i18n.rb | 19 | 
2 files changed, 14 insertions, 7 deletions
| diff --git a/app/models/vehicle_journey_import.rb b/app/models/vehicle_journey_import.rb index 250f3a9e9..f06b1bfaf 100644 --- a/app/models/vehicle_journey_import.rb +++ b/app/models/vehicle_journey_import.rb @@ -3,6 +3,8 @@ class VehicleJourneyImport    include ActiveModel::Conversion    extend  ActiveModel::Naming +  extend EnhancedModelI18n +    attr_accessor :file, :route    attr_accessor :created_vehicle_journey_count,:updated_vehicle_journey_count,:deleted_vehicle_journey_count    attr_accessor :created_journey_pattern_count,:error_count 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 | 
