Module: StompBase::I18nHelper

Included in:
ApplicationController, ApplicationHelper
Defined in:
lib/stomp_base/i18n_helper.rb

Instance Method Summary collapse

Instance Method Details

#available_localesObject



13
14
15
# File 'lib/stomp_base/i18n_helper.rb', line 13

def available_locales
  StompBase.configuration.available_locales
end

#current_localeObject



17
18
19
# File 'lib/stomp_base/i18n_helper.rb', line 17

def current_locale
  StompBase.locale
end

#locale_name(locale) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/stomp_base/i18n_helper.rb', line 21

def locale_name(locale)
  case locale.to_sym
  when :en
    "English"
  when :ja
    "日本語"
  else
    locale.to_s.capitalize
  end
end

#t(key, options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/stomp_base/i18n_helper.rb', line 5

def t(key, options = {})
  # For StompBase-specific translation keys, automatically add prefix
  key_string = key.to_s
  key = "stomp_base.#{key_string}" unless key_string.start_with?("stomp_base.")

  I18n.t(key, **options, locale: StompBase.locale)
end