aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
diff options
context:
space:
mode:
authorSameer Rahmani <lxsameer@gnu.org>2015-12-01 19:19:44 +0330
committerSameer Rahmani <lxsameer@gnu.org>2015-12-18 22:45:05 +0330
commitc1dbb13eacf0e579f351a46c9ee2ec845ae0cc2d (patch)
treec2fef94c1127e7732ed7ab87728d522960fbdad6 /actionview/lib/action_view/helpers
parentcd53b05be8f74dfc9c872eb1e84cd024e754f48d (diff)
downloadrails-c1dbb13eacf0e579f351a46c9ee2ec845ae0cc2d.tar.gz
rails-c1dbb13eacf0e579f351a46c9ee2ec845ae0cc2d.tar.bz2
rails-c1dbb13eacf0e579f351a46c9ee2ec845ae0cc2d.zip
debug_missing_translation configuration added to action_view
`I18n.translate` helper will wrap the missing translation keys in a <span> tag only if `debug_missing_translation` configuration has a truthy value. Default value is `true`. For example in `application.rb`: # in order to turn off missing key wrapping config.action_view.debug_missing_translation = false
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 4c4d2c4457..152e1b1211 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -6,7 +6,15 @@ module ActionView
# = Action View Translation Helpers
module Helpers
module TranslationHelper
+ extend ActiveSupport::Concern
+
include TagHelper
+
+ included do
+ mattr_accessor :debug_missing_translation
+ self.debug_missing_translation = true
+ end
+
# Delegates to <tt>I18n#translate</tt> but also performs three additional
# functions.
#
@@ -95,6 +103,8 @@ module ActionView
title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(', ')
end
+ return title unless ActionView::Base.debug_missing_translation
+
content_tag('span', keys.last.to_s.titleize, class: 'translation_missing', title: title)
end
end