Skip to content

Commit

Permalink
Merge pull request #61 from b310-digital/60-allow-detection-of-source…
Browse files Browse the repository at this point in the history
…-language

[Feature]: Allow the automatic detection of the source language #60
  • Loading branch information
dustessavdh authored Aug 25, 2024
2 parents f7e7a00 + 9969177 commit 165b4dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/deepl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ defmodule DeeplEx.DeepL do
text: [
text
],
source_lang: parse_language(source_language),
target_lang: parse_language(target_language)
})

content =
if source_language == :DETECT do
# no need to set source_language, deepl will try to detect the source_language:
content
else
Map.merge(content, %{source_lang: parse_language(source_language)})
end

Tesla.post(client, "/translate", content)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/helpers/language_validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ defmodule DeeplEx.LanguageValidator do
:SV,
:TR,
:UK,
:ZH
:ZH,
:DETECT
]

@valid_target_languages [
Expand Down

0 comments on commit 165b4dc

Please sign in to comment.