Class: Tolq::Parsers::Xliff::Unparser

Inherits:
Object
  • Object
show all
Defined in:
lib/xliff/unparser.rb

Overview

Unparses a tolq response to xliff suitable As opposed to other unparsers, requires the original, AND the target language code Assumes single file per xliff

Instance Method Summary collapse

Instance Method Details

#from_hash(translations, original:, target_language_code:) ⇒ String

Unparses a translations hash of key => translation

Parameters:

  • translations (Hash)

    A hash of translations with key => translation

Returns:

  • (String)

    A xliff formatted string



20
21
22
# File 'lib/xliff/unparser.rb', line 20

def from_hash(translations, original:, target_language_code:)
  translate_xliff(translations, original, target_language_code).to_s
end

#from_tolq_response(tolq_response, original:, target_language_code:) ⇒ String

Unparses the tolq response

Parameters:

  • tolq_response (Hash)

    A parsed response from our api

Returns:

  • (String)

    A xliff formatted string



11
12
13
14
# File 'lib/xliff/unparser.rb', line 11

def from_tolq_response(tolq_response, original:, target_language_code:)
  translations = tolq_response['translations'].values.first
  translate_xliff(translations, original, target_language_code).to_s
end