Class: Any2Tmx::Transformer
- Inherits:
-
Object
- Object
- Any2Tmx::Transformer
- Defined in:
- lib/any2tmx/transformer.rb
Constant Summary collapse
- EXTRACTOR_EXTENSIONS =
{ '.yml' => 'yaml/rails', '.json' => 'json/key-value', '.xml' => 'android/xml', '.txt' => 'txt/lines' }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Transformer
constructor
A new instance of Transformer.
- #transform ⇒ Object
Constructor Details
#initialize(options) ⇒ Transformer
Returns a new instance of Transformer.
14 15 16 |
# File 'lib/any2tmx/transformer.rb', line 14 def initialize() = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/any2tmx/transformer.rb', line 12 def end |
Instance Method Details
#transform ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/any2tmx/transformer.rb', line 18 def transform source_phrases = extract_from(.source[:file]) result = source_phrases.each_with_object({}) do |(k, v), result| result[k] = { .source[:locale] => v.to_s } end .targets.each do |target| target_phrases = extract_from(target[:file]) source_phrases.each_pair do |source_key, _| translation = target_phrases[source_key] if !translation.nil? result[source_key][target[:locale]] = translation.to_s end end end result end |