Class: Aws::Translate::Plugins::TranslateDocumentEncoding::Handler Private

Inherits:
Seahorse::Client::Handler
  • Object
show all
Defined in:
lib/aws-sdk-translate/plugins/translate_document_encoding.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#call(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aws-sdk-translate/plugins/translate_document_encoding.rb', line 12

def call(context)
  # detect encoding
  document = context.params[:document]
  encoding =
    if document[:content_type].start_with?('text/') && document[:content].is_a?(String)
      document[:content].encoding
    end
  resp = @handler.call(context)
  if encoding
    resp.translated_document.content = resp.translated_document.content.force_encoding(encoding)
  end
  resp
end