Module: Formtastic::I18n

Defined in:
lib/formtastic/i18n.rb

Constant Summary collapse

DEFAULT_SCOPE =
[:formtastic].freeze
DEFAULT_VALUES =
{
  :required       => 'required',
  :yes            => 'Yes',
  :no             => 'No',
  :create         => 'Create %{model}',
  :update         => 'Update %{model}'
}.freeze
SCOPES =
[
  '%{model}.%{nested_model}.%{action}.%{attribute}',
  '%{model}.%{action}.%{attribute}',
  '%{model}.%{nested_model}.%{attribute}',
  '%{model}.%{attribute}',
  '%{nested_model}.%{attribute}',
  '%{attribute}'
]

Class Method Summary collapse

Class Method Details

.translate(*args) ⇒ Object Also known as: t



23
24
25
26
27
28
29
# File 'lib/formtastic/i18n.rb', line 23

def translate(*args)
  key = args.shift.to_sym
  options = args.extract_options!
  options.reverse_merge!(:default => DEFAULT_VALUES[key])
  options[:scope] = [DEFAULT_SCOPE, options[:scope]].flatten.compact
  ::I18n.translate(key, *(args << options))
end