From e13c179499f227071cbe829221877e1c0d03c0b1 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 8 Mar 2010 19:55:57 -0200 Subject: Change array entries to safe doesn't worth then the array is joined as a string losing the safe property of his entries [#4134 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/lib/action_view/helpers/translation_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/translation_helper.rb') diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index 8a89ee58a0..f996762d6f 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -13,7 +13,7 @@ module ActionView def translate(key, options = {}) options[:raise] = true translation = I18n.translate(scope_key_by_partial(key), options) - translation.is_a?(Array) ? translation.map { |entry| entry.html_safe } : translation.html_safe + translation.respond_to?(:html_safe) ? translation.html_safe : translation rescue I18n::MissingTranslationData => e keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]) content_tag('span', keys.join(', '), :class => 'translation_missing') -- cgit v1.2.3 From 12bf636461e3aab661119ceb3a104cfb70a11666 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 16 Mar 2010 17:36:09 -0300 Subject: translation method of TranslationHelper module returns always SafeBuffer [#4194 status:resolved] Signed-off-by: Jeremy Kemper --- actionpack/lib/action_view/helpers/translation_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers/translation_helper.rb') diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index f996762d6f..26ba4e2ca4 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -13,7 +13,7 @@ module ActionView def translate(key, options = {}) options[:raise] = true translation = I18n.translate(scope_key_by_partial(key), options) - translation.respond_to?(:html_safe) ? translation.html_safe : translation + (translation.respond_to?(:join) ? translation.join : translation).html_safe rescue I18n::MissingTranslationData => e keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]) content_tag('span', keys.join(', '), :class => 'translation_missing') -- cgit v1.2.3 From 0c1ac36ccb7d72f3d17d950d030442a7e83d0708 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 16 Mar 2010 20:12:04 -0300 Subject: scope_key_by_partial fix for Ruby 1.9 when there's virtual_path [#4202 state:resolved] Signed-off-by: Jeremy Kemper --- actionpack/lib/action_view/helpers/translation_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers/translation_helper.rb') diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index 26ba4e2ca4..457944dbb6 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -29,9 +29,10 @@ module ActionView private def scope_key_by_partial(key) - if (key.respond_to?(:join) ? key.join : 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 -- cgit v1.2.3