2008-07-06 13:00:55 -04:00
|
|
|
require 'action_view/helpers/tag_helper'
|
|
|
|
|
|
|
|
module ActionView
|
|
|
|
module Helpers
|
|
|
|
module TranslationHelper
|
2008-10-28 11:51:08 -04:00
|
|
|
def translate(key, options = {})
|
|
|
|
options[:raise] = true
|
|
|
|
I18n.translate(key, options)
|
2008-07-06 13:00:55 -04:00
|
|
|
rescue I18n::MissingTranslationData => e
|
2008-10-28 11:51:08 -04:00
|
|
|
keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
|
2008-07-06 13:00:55 -04:00
|
|
|
content_tag('span', keys.join(', '), :class => 'translation_missing')
|
|
|
|
end
|
2008-08-25 05:06:18 -04:00
|
|
|
alias :t :translate
|
2008-07-08 06:37:49 -04:00
|
|
|
|
|
|
|
def localize(*args)
|
2008-07-16 14:07:08 -04:00
|
|
|
I18n.localize *args
|
2008-07-08 06:37:49 -04:00
|
|
|
end
|
2008-08-25 05:06:18 -04:00
|
|
|
alias :l :localize
|
2008-07-06 13:00:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|