lib/action_view/helpers/translation_helper.rb in actionpack-3.0.0.beta vs lib/action_view/helpers/translation_helper.rb in actionpack-3.0.0.beta2
- old
+ new
@@ -10,13 +10,14 @@
# people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo"). This makes it less repetitive
# to translate many keys within the same partials and gives you a simple framework for scoping them consistently. If you don't
# prepend the key with a period, nothing is converted.
def translate(key, options = {})
options[:raise] = true
- I18n.translate(scope_key_by_partial(key), options).html_safe
+ translation = I18n.translate(scope_key_by_partial(key), options)
+ (translation.respond_to?(:join) ? translation.join : translation).html_safe
rescue I18n::MissingTranslationData => e
- keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
+ keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
content_tag('span', keys.join(', '), :class => 'translation_missing')
end
alias :t :translate
# Delegates to I18n.localize with no additional functionality.
@@ -26,18 +27,19 @@
alias :l :localize
private
def scope_key_by_partial(key)
- if key.to_s.first == "."
+ strkey = key.respond_to?(:join) ? key.join : key.to_s
+ if strkey.first == "."
if @_virtual_path
- @_virtual_path.gsub(%r{/_?}, ".") + key.to_s
+ @_virtual_path.gsub(%r{/_?}, ".") + strkey
else
raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
end
else
key
end
end
end
end
-end
\ No newline at end of file
+end