Class: Hydramata::Core::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/hydramata/core/translator.rb

Overview

Responsible for handling the translation via diminishing specificity.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Translator

Returns a new instance of Translator.



16
17
18
19
20
# File 'lib/hydramata/core/translator.rb', line 16

def initialize(options = {})
  self.base_scope = options.fetch(:base_scope) { default_base_scope }
  @translation_service = options.fetch(:translation_service) { default_translation_service }
  @translation_service_error = options.fetch(:translation_service_error) { default_translation_service_error }
end

Instance Attribute Details

#base_scopeObject

Returns the value of attribute base_scope.



15
16
17
# File 'lib/hydramata/core/translator.rb', line 15

def base_scope
  @base_scope
end

#translation_serviceObject (readonly)

Returns the value of attribute translation_service.



15
16
17
# File 'lib/hydramata/core/translator.rb', line 15

def translation_service
  @translation_service
end

#translation_service_errorObject (readonly)

Returns the value of attribute translation_service_error.



15
16
17
# File 'lib/hydramata/core/translator.rb', line 15

def translation_service_error
  @translation_service_error
end

Class Method Details

.tObject



12
13
14
# File 'lib/hydramata/core/translator.rb', line 12

def translate(key, options = {})
  new(options).translate(key, options)
end

.translate(key, options = {}) ⇒ Object



9
10
11
# File 'lib/hydramata/core/translator.rb', line 9

def translate(key, options = {})
  new(options).translate(key, options)
end

Instance Method Details

#translate(key, options = {}) ⇒ Object Also known as: t



22
23
24
# File 'lib/hydramata/core/translator.rb', line 22

def translate(key, options = {})
  translate_key_for_specific_scopes(key, options) || translate_key_for_general_case(key, options)
end