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 | |
| parent | a4c0a3c90bf08b072af2afafd354b424af87d585 (diff) | |
| download | chouette-core-fc684594b6075ce6e35a983e085a777682d505b7.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 |
