diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2013-01-15 15:24:22 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2013-01-15 15:24:22 +1100 |
commit | 7a30900852b6fb3661f07c368796a78af434f9d9 (patch) | |
tree | 809a455ddabe78f7fe386ebbde3f59533404fcbf /lib/i18n_fixes.rb | |
parent | 0bf282eff6912b8a2b03a461b3f62821a8f0cf55 (diff) |
There's no way that gettext_interpolate would work when not passed a hash - untested and unused. So removing.
Diffstat (limited to 'lib/i18n_fixes.rb')
-rw-r--r-- | lib/i18n_fixes.rb | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/lib/i18n_fixes.rb b/lib/i18n_fixes.rb index 7d6ddb80d..5fb5f03b7 100644 --- a/lib/i18n_fixes.rb +++ b/lib/i18n_fixes.rb @@ -19,35 +19,25 @@ MATCH = /\{\{([^\}]+)\}\}/ def gettext_interpolate(string, values) return string unless string.is_a?(String) - if values.is_a?(Hash) - # $1, $2 don't work with SafeBuffer so casting to string as workaround - safe = string.html_safe? - string = string.to_str.gsub(MATCH) do - pattern, key = $1, $1.to_sym - - if INTERPOLATION_RESERVED_KEYS.include?(pattern) - raise I18n::ReservedInterpolationKey.new(pattern, string) - elsif !values.include?(key) - raise I18n::MissingInterpolationArgument.new(pattern, string) + # $1, $2 don't work with SafeBuffer so casting to string as workaround + safe = string.html_safe? + string = string.to_str.gsub(MATCH) do + pattern, key = $1, $1.to_sym + + if INTERPOLATION_RESERVED_KEYS.include?(pattern) + raise I18n::ReservedInterpolationKey.new(pattern, string) + elsif !values.include?(key) + raise I18n::MissingInterpolationArgument.new(pattern, string) + else + v = values[key].to_s + if safe && !v.html_safe? + ERB::Util.h(v) else - v = values[key].to_s - if safe && !v.html_safe? - ERB::Util.h(v) - else - v - end + v end end - safe ? string.html_safe : string - else - reserved_keys = if defined?(I18n::RESERVED_KEYS) # rails 3+ - I18n::RESERVED_KEYS - else - I18n::Backend::Base::RESERVED_KEYS - end - - string % values.except(*reserved_keys) end + safe ? string.html_safe : string end |