Class: Hydramata::Core::Translator
- Inherits:
-
Object
- Object
- Hydramata::Core::Translator
- Defined in:
- lib/hydramata/core/translator.rb
Overview
Responsible for handling the translation via diminishing specificity.
Instance Attribute Summary collapse
-
#base_scope ⇒ Object
readonly
Returns the value of attribute base_scope.
-
#translation_service ⇒ Object
readonly
Returns the value of attribute translation_service.
-
#translation_service_error ⇒ Object
readonly
Returns the value of attribute translation_service_error.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Translator
constructor
A new instance of Translator.
- #translate(key, options = {}) ⇒ Object (also: #t)
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( = {}) self.base_scope = .fetch(:base_scope) { default_base_scope } @translation_service = .fetch(:translation_service) { default_translation_service } @translation_service_error = .fetch(:translation_service_error) { default_translation_service_error } end |
Instance Attribute Details
#base_scope ⇒ Object
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_service ⇒ Object (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_error ⇒ Object (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
.t ⇒ Object
12 13 14 |
# File 'lib/hydramata/core/translator.rb', line 12 def translate(key, = {}) new().translate(key, ) end |
.translate(key, options = {}) ⇒ Object
9 10 11 |
# File 'lib/hydramata/core/translator.rb', line 9 def translate(key, = {}) new().translate(key, ) 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, = {}) translate_key_for_specific_scopes(key, ) || translate_key_for_general_case(key, ) end |