View Source DeeplEx (DeepL Ex v0.3.0)

Translate text using the DeepL api.

Summary

Functions

This function translates the given text from the given source language, to the given target language. It either returns {:ok, translation} or {:error, error}.

Functions

Link to this function

translate(text, source_language, target_language, options \\ %{})

View Source

This function translates the given text from the given source language, to the given target language. It either returns {:ok, translation} or {:error, error}.

See DeeplEx.LanguageValidator and DeeplEx.OptionsValidator for more information about the allowed values.

Example with correct input

  iex> DeeplEx.translate("Hoje vou comer.", :PT, :EN)
  {:ok, "Today I'm going to eat."}

Example when using an incorrect language atom

  iex> DeeplEx.translate("Hoje vou comer.", :ZZ, :EN)
  {:error, :invalid_language_specification}

Example when using options

  iex> DeeplEx.translate("Hello, how are you?", :EN, :PT_BR, %{formality: "less"})
  {:ok, "Olá, cara, como você está?"}