Module: I18nliner::Extensions::View

Includes:
Inferpolation
Defined in:
lib/i18nliner/extensions/view.rb

Instance Method Summary collapse

Methods included from Inferpolation

#inferpolate, #inferpolate_value!

Instance Method Details

#i18nliner_scopeObject


10
# File 'lib/i18nliner/extensions/view.rb', line 10

def i18nliner_scope; end

#translate(*args) ⇒ Object Also known as: t, t!, translate!


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/i18nliner/extensions/view.rb', line 12

def translate(*args)
  # if a block gets through to here, it either means:
  # 1. the user did something weird (e.g. <%= t{ "haha" } %>)
  # 2. the erb pre processor missed it somehow (bug)
  raise InvalidBlockUsageError.new("block translate calls need to be output (i.e. `<%=`) and the block body must be of the form `%>your string<%`") if block_given?
  key, options = CallHelpers.infer_arguments(args)
  options = inferpolate(options) if I18nliner.infer_interpolation_values
  options[:i18nliner_scope] = i18nliner_scope
  super(key, options)
rescue ArgumentError
  raise
end