summaryrefslogtreecommitdiff
path: root/engines/support/app/helpers/ticket_i18n_helper.rb
blob: 61b4cf28988fee92ed2c82e8c1a2b8204b4ff7f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module TicketI18nHelper

  #
  # outputs translations for all the possible translated strings.
  # used in emails, sense we don't know the locale of the recipient.
  #
  def t_all_available(key)
    default = I18n.t(key, locale: I18n.default_locale)
    result = []
    result << "[#{I18n.default_locale}] #{default}"
    I18n.available_locales.each do |locale|
      text = I18n.t(key, locale: locale, default: default)
      if text != default
        result << "[#{locale}] #{text}"
      end
    end
    result.join("\n")
  end

end