aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers
diff options
context:
space:
mode:
authorAlban Peignier2018-03-22 17:46:35 +0100
committerAlban Peignier2018-03-22 17:46:35 +0100
commit9a7aa3c98206f83f70cee67e6f67b289537dd2c0 (patch)
tree8177f4b49b1c00ebd45fd30f8973b1572908b01d /config/initializers
parent246382fd77799e4cf1a04578be0d8f0e982a5164 (diff)
downloadchouette-core-9a7aa3c98206f83f70cee67e6f67b289537dd2c0.tar.bz2
Fixe features/vehicle_journey_imports spec. Refs #6296
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/i18n.rb19
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