Deepl.Text (deepl v0.1.2)
View SourceModule for translating text using the DeepL API.
Summary
Functions
Translates a single or multiple texts to the specified target language.
Translates a single or multiple texts to the specified target language.
Types
Functions
Translates a single or multiple texts to the specified target language.
The text
parameter can be a single string or a list of strings.
Examples
iex> Deepl.Text.translate("Hello World", "ID")
%{
"translations" => [
%{"detected_source_language" => "EN", "text" => "Halo Dunia"}
]
}}
iex> Deepl.Text.translate(["Hello World", "Hello Developer"], "ID")
{:ok,
%{
"translations" => [
%{"detected_source_language" => "EN", "text" => "Halo Dunia"},
%{"detected_source_language" => "EN", "text" => "Halo Pengembang"}
]
}}
iex> Deepl.Text.translate("Hello World", "ID", show_billed_characters: true)
{:ok,
%{
"translations" => [
%{
"billed_characters" => 11,
"detected_source_language" => "EN",
"text" => "Halo Dunia"
}
]
}}
@spec translate!(text(), binary(), Keyword.t()) :: map() | Exception.t()
Translates a single or multiple texts to the specified target language.
This function like translate/3
, but raises an error if the translation fails.