mirror of
https://github.com/Syping/dtranslatebot.git
synced 2026-04-01 05:20:22 +02:00
deepl: alias source and target for more compatibility
This commit is contained in:
parent
5e3808204e
commit
db8a915afd
1 changed files with 3 additions and 3 deletions
|
|
@ -84,10 +84,10 @@ const std::string deepl::translate(const std::string &text, const std::string &s
|
||||||
{
|
{
|
||||||
dpp::json json_body = {
|
dpp::json json_body = {
|
||||||
{"text", { text } },
|
{"text", { text } },
|
||||||
{"target_lang", target}
|
{"target_lang", target == "en" ? "en-US" : target == "pt" ? "pt-PT" : target}
|
||||||
};
|
};
|
||||||
if (!source.empty())
|
if (!source.empty() && source != "auto")
|
||||||
json_body["source_lang"] = source;
|
json_body["source_lang"] = source.length() > 2 ? source.substr(0, 2) : source;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http_response response = m_http.post(http_request::legacy_url(m_hostname, 443, "/v2/translate", true), json_body.dump(),
|
http_response response = m_http.post(http_request::legacy_url(m_hostname, 443, "/v2/translate", true), json_body.dump(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue