Files
nairobi/config/initializers/i18n_translation.rb
Javi Martín ea2aeab383 Apply rubocop Rails/FindBy rule everywhere
We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
2019-11-08 19:15:04 +01:00

20 lines
562 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
i18_content = I18nContent.find_by(key: key)
translation = I18nContentTranslation.find_by(i18n_content_id: i18_content&.id,
locale: current_locale)&.value
translation.presence || translate(key, options)
end
end
end
end