Class: I18nJsAssets::Processor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/i18n-js-assets/processor.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(scope, locals) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/i18n-js-assets/processor.rb', line 12

def evaluate(scope, locals)
  options = (YAML.load(data) || {}).with_indifferent_access
  only = options.fetch(:only, '*')
  exceptions = [options.fetch(:except, [])].flatten

  # handle newer and older versions of i18n-js
  translations = if i18n_js.method(:segment_for_scope).arity == 2
    i18n_js.segment_for_scope(only, exceptions)
  else
    i18n_js.segment_for_scope(only)
  end

  locales = options.fetch(:locales, translations.keys).map(&:to_sym)

  construct_javascript_from(locales, translations)
end

#prepareObject



8
9
10
# File 'lib/i18n-js-assets/processor.rb', line 8

def prepare
  # noop
end