tisfeng / Easydict

一个简洁优雅的词典翻译 macOS App。开箱即用,支持离线 OCR 识别,支持有道词典,🍎 苹果系统词典,🍎 苹果系统翻译,OpenAI,Gemini,DeepL,Google,Bing,腾讯,百度,阿里,小牛,彩云和火山翻译。A concise and elegant Dictionary and Translator macOS App for looking up words and translating text.
GNU General Public License v3.0
7.02k stars 356 forks source link

Added support for translation to Brazilian Portuguese. #586

Closed NeverAgain11 closed 3 months ago

NeverAgain11 commented 3 months ago

569

NeverAgain11 commented 3 months ago

@tisfeng

新增支持翻译到巴西葡萄牙语时,用 pt-BR 时请求翻译出现错误.

Bind 翻译的错误是:

bing json parse failed { "errorMessage" : "", "statusCode" : 400 }}

DeepL 的错误是:

Request failed: bad request (400) Invalid Request

能帮忙看看是什么问题么?

tisfeng commented 3 months ago

ok,明天我看看。

Jerry23011 commented 3 months ago
截屏2024-06-13 01 37 00

DeepL works on my end

Jerry23011 commented 3 months ago

As for Bing, it just doesn't seem to support pt-BR? 截屏2024-06-13 02 00 12

截屏2024-06-13 02 00 47
NeverAgain11 commented 3 months ago

@Jerry23011 Could you try to translate from Chinese text to pt-BR?

Jerry23011 commented 3 months ago

@Jerry23011 Could you try to translate from Chinese text to pt-BR?

When targeting pt-BR, DeepL says Invalid target_lang

{
  "jsonrpc": "2.0",
  "id": 150256000,
  "error": {
    "code": -32600,
    "message": "Invalid Request",
    "data": {
      "what": "Invalid target_lang."
    }
  }
}

I'm not familiar with the implementation of DeepL in Easydict, but it seems pt-BR is supported as a target lang in their docs?

tisfeng commented 3 months ago

The official API of DeepL supports PT-BR language, but the web version of our API does not support it.

image
tisfeng commented 3 months ago

I just added DeepL support for regional variant languages, like pt-BR 1cc75611

image
tisfeng commented 3 months ago

Note that I just debugged the Bing web API and found that the current code for the Portuguese language is wrong, it's a bit strange, for Portuguese Portuguese it's pt-PT, for Brazilian Portuguese it's pt 😓

I have fixed it adde77e1 .

Bing Brazilian Portuguese translate

image image
Jerry23011 commented 3 months ago

The latest changes works on my end

NeverAgain11 commented 3 months ago

I checked other services and added support for Baidu, Google and Niu. The Google translation has the same effect when using pt, pt-PT and pt-BR.

tisfeng commented 3 months ago

The Google translation has the same effect when using pt, pt-PT and pt-BR.

It seems Google Translate doesn't support pt-BR, and the web version doesn't have the Brazilian Portuguese language option either.