From a61a6d206b1d37747c3f907487db4bc0952c7b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 1 May 2010 22:38:57 +0200 Subject: Speed up I18n helpers in views and add entry to CHANGELOG. --- actionpack/lib/action_view/helpers/translation_helper.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index 89c1b4a275..086ad261c8 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -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 -- cgit v1.2.3