DeepLcom / deepl-rb

Official Ruby library for the DeepL language translation API.
https://www.deepl.com
MIT License
8 stars 2 forks source link

translate_document throws `Error occurred during document translation: no implicit conversion of nil into String (DeepL::Exceptions::DocumentTranslationError)` when source language is `nil` #8

Open jtzero opened 1 week ago

jtzero commented 1 week ago

translate_document states that param can be nil or string

    # @param [String, nil] source_lang Source language to use for the translation. `nil` will cause
    #                                  automatic source langauge detection to be used. Must be

however when passing in a nil it errors

input_document = Tempfile.new(['deep_l', '.html']).tap do |file|
  file.write('<html>Bonjour</html>')
  file.rewind
end
output_document_path = ::Dir::Tmpname.create('deep_l') {}
DeepL.document.translate_document(
  input_document.path,
  output_document_path,
  nil,
  'EN',
  nil,
  tag_handling: 'html',
)

Using an empty string does work