Class: Translatomatic::Translator::Base Abstract
- Inherits:
-
Object
- Object
- Translatomatic::Translator::Base
- Extended by:
- DefineOptions
- Includes:
- Util
- Defined in:
- lib/translatomatic/translator/base.rb
Overview
This class is abstract.
Class Attribute Summary collapse
-
.options ⇒ Object
readonly
Returns the value of attribute options.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#languages ⇒ Array<String>
A list of languages supported by this translator.
-
#name ⇒ String
The name of this translator.
-
#translate(strings, from, to) ⇒ Array<String>
Translate strings from one locale to another.
Methods included from Util
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
17 18 19 |
# File 'lib/translatomatic/translator/base.rb', line 17 def initialize( = {}) @listener = [:listener] end |
Class Attribute Details
.options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/translatomatic/translator/base.rb', line 9 def @options end |
Instance Attribute Details
#listener ⇒ Object
15 16 17 |
# File 'lib/translatomatic/translator/base.rb', line 15 def listener @listener end |
Instance Method Details
#languages ⇒ Array<String>
Returns A list of languages supported by this translator.
27 28 29 |
# File 'lib/translatomatic/translator/base.rb', line 27 def languages [] end |
#name ⇒ String
Returns The name of this translator.
22 23 24 |
# File 'lib/translatomatic/translator/base.rb', line 22 def name self.class.name.demodulize end |
#translate(strings, from, to) ⇒ Array<String>
Translate strings from one locale to another
36 37 38 39 40 41 42 43 44 |
# File 'lib/translatomatic/translator/base.rb', line 36 def translate(strings, from, to) strings = [strings] unless strings.kind_of?(Array) from = locale(from) to = locale(to) return strings if from.language == to.language translated = perform_translate(strings, from, to) update_translated(translated) unless @updated_listener translated end |