Sha256: 0aecd5973d6ef916e4496719eed628850e653dd8318983980dfaaa685388afe3
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
module I18nScrewdriver class Translation < ActiveSupport::SafeBuffer def self.new(text, options = {}, &block) super(I18n.translate(I18nScrewdriver.for_key(text), options)).tap do |translation| translation.linkify(block.binding, *block.call) if block end end def linkify(binding, *urls) context = binding ? eval('self', binding) : self keep_html_safety do gsub!(/<<.+?>>/).each_with_index do |text, index| context.instance_eval do link_to text[2..-3], *urls[index] end end end end private def keep_html_safety html_safe = @html_safe yield @html_safe = html_safe self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n_screwdriver-2.1.1 | lib/i18n_screwdriver/translation.rb |
i18n_screwdriver-2.1.0 | lib/i18n_screwdriver/translation.rb |