Sha256: 12687c9e12abd01660e66db72c5d27585fb06d17460a9be5e2f5401060e88b01
Contents?: true
Size: 941 Bytes
Versions: 46
Compression:
Stored size: 941 Bytes
Contents
ActionView::Helpers::TranslationHelper.module_eval do # simple wrapper around the translate helper # it implements a dryml <translate> and a <t> tag # Improved security: interpolated variables are escaped # Improved management: when it returns a string it is always html_safe # It assumes the base translation string is html_safe # It removes the <span> tag when the key is missing, because it would mess up # the dryml tags when ht or t is used in some place def translate(key, options={}) key, options = normalize_args(key, options) translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true)) if translation.respond_to?(:html_safe) translation.html_safe else translation end rescue I18n::MissingTranslationData => e keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]).join('.') "[MISSING: #{keys}]" end alias_method :t, :translate end
Version data entries
46 entries across 46 versions & 1 rubygems