lib/i18n_screwdriver/translation.rb in i18n_screwdriver-3.0.1 vs lib/i18n_screwdriver/translation.rb in i18n_screwdriver-4.0.0
- old
+ new
@@ -1,7 +1,7 @@
module I18nScrewdriver
- class Translation < ActiveSupport::SafeBuffer
+ class Translation < String
attr_accessor :text, :options
def self.new(text, options = {}, &block)
translation = super(options[:raw] ? text : I18n.translate(I18nScrewdriver.for_key(text), options))
translation.text = text
@@ -10,10 +10,10 @@
if block
urls = Array(block.call)
urls_to_interpolate_count = translation.scan(/<<.+?>>/).count
raise ArgumentError, "too few urls specified" if urls.count < urls_to_interpolate_count
if urls.count > urls_to_interpolate_count
- raise ArgumentError, "expected extra url to be a hash intended for variable interpolation" unless urls.last.is_a?(Hash)
+ raise ArgumentError, "too many urls specified (#{urls.count} <> #{urls_to_interpolate_count})" unless urls.last.is_a?(Hash)
translation = new(translation % urls.last, :raw => true)
end
translation.linkify(block.binding, urls)
end