lokalise / i18n-ally

🌍 All in one i18n extension for VS Code
https://marketplace.visualstudio.com/items?itemName=lokalise.i18n-ally
MIT License
3.96k stars 318 forks source link

DeepL Free Api fails with response Code 400 #622

Closed alexanderniebuhr closed 3 years ago

alexanderniebuhr commented 3 years ago

Describe the bug

Using DeepL free API, fails with Online Translate with response code 400, with following settings

    "i18n-ally.translate.deepl.apiKey": "***:fx",
    "i18n-ally.translate.deepl.enableLog": true,
    "i18n-ally.translate.deepl.useFreeApiEntry": true,

Extension Version

v2.6.13 (since newer version are not working)

Framework/i18n package you are using

svelte-i18n

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

πŸ› ERROR: Error: Request failed with status code 400
Error: Request failed with status code 400
    at createError (c:\Users\Alexander\.vscode-insiders\extensions\lokalise.i18n-ally-2.6.13\dist\extension.js:63042:15)
    at settle (c:\Users\Alexander\.vscode-insiders\extensions\lokalise.i18n-ally-2.6.13\dist\extension.js:94238:12)
    at IncomingMessage.handleStreamEnd (c:\Users\Alexander\.vscode-insiders\extensions\lokalise.i18n-ally-2.6.13\dist\extension.js:190885:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
alexanderniebuhr commented 3 years ago

tested with 2.6.17 - not working

alexanderniebuhr commented 3 years ago

@terales @antfu sorry for tagging you guys Might have a Setup, issue but I doubt that for now. I would like to debug more, but I don't get the request to the DeepL API logged. But getting this done is higher in my priority list than my feature request. Just saying, currently this is a blocker, since we have to fall back to the least optimal google translation :/

antfu commented 3 years ago

Hey @OsirisFrik, could you help to take a look at this and see if it's persist on your side? Thanks.

OsirisFrik commented 3 years ago

I checked this and read the documentation, to use a DeepL free api require a free api key, my country is not allowed to contract DeepL, and I don't have any credit card of a allowed country to contract for test, but I can fix it just based in the docs.

alexanderniebuhr commented 3 years ago

@OsirisFrik @antfu I am using a free api key generated for my user, and it does throw the error 400.

antfu commented 3 years ago

@alexanderniebuhr I have make the logger print more information in #641. While I can't not reproduce myself, you can try with the latest version and share the error log? Thanks

alexanderniebuhr commented 3 years ago
🌎⚠️ Failed to translate "page.login.headline" (de-DE->en-GB)
πŸ› ERROR: Error: Request failed with status code 400
Error: Request failed with status code 400
    at createError (/Users/alexanderniebuhr/.vscode-insiders/extensions/lokalise.i18n-ally-2.6.24/dist/extension.js:116796:15)
    at settle (/Users/alexanderniebuhr/.vscode-insiders/extensions/lokalise.i18n-ally-2.6.24/dist/extension.js:117071:12)
    at IncomingMessage.handleStreamEnd (/Users/alexanderniebuhr/.vscode-insiders/extensions/lokalise.i18n-ally-2.6.24/dist/extension.js:116146:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

EDIT: can it be caused, because we use language identifiers with two parts, e.g. en-GB?

alexanderniebuhr commented 3 years ago

As soon as I change i18n-ally.translate.engines back to google it works.

antfu commented 3 years ago

Not sure, can you try with de -> en?

alexanderniebuhr commented 3 years ago

yeah.. de -> en works.. but de-DE -> en-GB does not work. Can you split these in code, since we do need to use full identifiers in our projects. Here the docs what is supported source and target languages: https://www.deepl.com/docs-api/translating-text/request/ Actually it should give back a api response, but that api response from deepl is not logged, maybe caused by an error thrown before logging

antfu commented 3 years ago

Ah ok then. We could strip the second code when passing to deepl then. Thanks for investigating!

alexanderniebuhr commented 3 years ago

always happy to help :) This is also helping me in our projects πŸš€