class LightService::I18n::LocalizationAdapter
Public Instance Methods
Source
# File lib/light-service/i18n/localization_adapter.rb, line 4 def failure(message_or_key, action_class, options = {}) find_translated_message(message_or_key, action_class, options.merge(:type => :failure)) end
Source
# File lib/light-service/i18n/localization_adapter.rb, line 10 def success(message_or_key, action_class, options = {}) find_translated_message(message_or_key, action_class, options.merge(:type => :success)) end
Private Instance Methods
Source
# File lib/light-service/i18n/localization_adapter.rb, line 18 def find_translated_message(message_or_key, action_class, options) if message_or_key.is_a?(Symbol) translate(message_or_key, action_class, options) else message_or_key end end
Source
# File lib/light-service/i18n/localization_adapter.rb, line 37 def i18n_scope_from_class(action_class, type) "#{action_class.name.underscore}.light_service.#{type.to_s.pluralize}" end
Source
# File lib/light-service/i18n/localization_adapter.rb, line 28 def translate(key, action_class, options = {}) type = options.delete(:type) scope = i18n_scope_from_class(action_class, type) options[:scope] = scope ::I18n.t(key, **options) end