class Slim::Translator
Public Class Methods
i18n_key(text)
click to toggle source
# File lib/slim/translator.rb, line 26 def self.i18n_key(text) key = text.parameterize.underscore I18n.t!(key) rescue I18n::MissingTranslationData text end
i18n_text(text)
click to toggle source
# File lib/slim/translator.rb, line 20 def self.i18n_text(text) I18n.t!(text) rescue I18n::MissingTranslationData text end
new(opts = {})
click to toggle source
Calls superclass method
# File lib/slim/translator.rb, line 37 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
Public Instance Methods
call(exp)
click to toggle source
Calls superclass method
# File lib/slim/translator.rb, line 33 def call(exp) options[:tr] ? super : exp end
on_slim_text(exp)
click to toggle source
# File lib/slim/translator.rb, line 49 def on_slim_text(exp) [:slim, :text, @translator.call(exp)] end