class Slim::Translator

@api private

def self.i18n_key(text)

def self.i18n_key(text)
  key = text.parameterize.underscore
  I18n.t!(key)
rescue I18n::MissingTranslationData
  text
end

def self.i18n_text(text)

def self.i18n_text(text)
  I18n.t!(text)
rescue I18n::MissingTranslationData
  text
end

def call(exp)

def call(exp)
  options[:tr] ? super : exp
end

def initialize(opts = {})

def initialize(opts = {})
  super
  case options[:tr_mode]
  when :static
    @translator = StaticTranslator.new(tr_fn: options[:tr_fn])
  when :dynamic
    @translator = DynamicTranslator.new(tr_fn: options[:tr_fn])
  else
    raise ArgumentError, "Invalid translator mode #{options[:tr_mode].inspect}"
  end
end

def on_slim_text(type, exp)

def on_slim_text(type, exp)
  [:slim, :text, type, @translator.call(exp)]
end