Files
grecia/config/initializers/i18n_translation.rb
Javi Martín 41dba842a6 Cache I18nContent translations
This way we avoid fetching each translation every time it's requested.
This reduces the amount of queries in the development logs and also
makes the test suite faster.
2020-12-15 11:57:09 +01:00

22 lines
479 B
Ruby

require "i18n/exceptions"
require "action_view/helpers/tag_helper"
module ActionView
module Helpers
module TranslationHelper
include TagHelper
def t(key, options = {})
current_locale = options[:locale].presence || I18n.locale
translation = I18nContent.translations_hash(current_locale)[key]
if translation.present?
translation % options
else
translate(key, options)
end
end
end
end
end