i18n_rails_helpers 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
data/app/helpers/i18n_helpers.rb
CHANGED
@@ -36,7 +36,7 @@ module I18nHelpers
|
|
36
36
|
# t_model(Account.new) => 'Konto'
|
37
37
|
# t_model => 'Konto' # when called in patients_controller views
|
38
38
|
#
|
39
|
-
def t_model(model = nil)
|
39
|
+
def t_model(model = nil, options = {})
|
40
40
|
if model.is_a? Class
|
41
41
|
model_name = model.name.underscore
|
42
42
|
elsif model.nil?
|
@@ -44,7 +44,10 @@ module I18nHelpers
|
|
44
44
|
else
|
45
45
|
model_name = model.class.name.underscore
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
|
+
options[:scope] = [:activerecord, :models]
|
49
|
+
options[:count] ||= 1
|
50
|
+
I18n::translate(model_name, *options)
|
48
51
|
end
|
49
52
|
|
50
53
|
# Returns translated title for current +action+ on +model+.
|
@@ -78,7 +81,7 @@ module I18nHelpers
|
|
78
81
|
I18n::translate("#{context}.#{action}.title", :default => [:"crud.title.#{action}"], :model => t_model(model))
|
79
82
|
end
|
80
83
|
alias :t_crud :t_title
|
81
|
-
|
84
|
+
|
82
85
|
# Returns translated string for current +action+.
|
83
86
|
#
|
84
87
|
# If no +action+ is given, it uses the current action.
|
@@ -94,7 +97,7 @@ module I18nHelpers
|
|
94
97
|
action ||= action_name
|
95
98
|
I18n::translate(action, :scope => 'crud.action', :model => t_model(model))
|
96
99
|
end
|
97
|
-
|
100
|
+
|
98
101
|
# Returns translated deletion confirmation for +record+.
|
99
102
|
#
|
100
103
|
# It uses +record+.to_s in the message.
|