Speed up I18n helpers in views and add entry to CHANGELOG.

This commit is contained in:
José Valim 2010-05-01 22:38:57 +02:00
parent 35598db01a
commit a61a6d206b
2 changed files with 5 additions and 7 deletions

View File

@ -20,7 +20,7 @@ module ActionView
options[:raise] = true
translation = I18n.translate(scope_key_by_partial(key), options)
translation = (translation.respond_to?(:join) ? translation.join : translation)
if html_safe_translation_key? key
if html_safe_translation_key?(key)
translation.html_safe
else
translation
@ -53,12 +53,8 @@ module ActionView
end
def html_safe_translation_key?(key)
last_key = if key.is_a? Array
key.last
else
key.to_s.split('.').last
end
(last_key == "html") || (last_key.ends_with? "_html")
key = key.is_a?(Array) ? key.last : key.to_s
key =~ /(\b|_|\.)html$/
end
end
end

View File

@ -1,5 +1,7 @@
*Rails 3.0.0 [beta 4/release candidate] (unreleased)*
* Deprecate {{}} as interpolation syntax for I18n in favor of %{} [José Valim]
* Array#to_xml is more powerful and able to handle the same types as Hash#to_xml #4490 [Neeraj Singh]
* Harmonize the caching API and refactor the backends. #4452 [Brian Durand]