thedaviddelta / lingva-translate

Alternative front-end for Google Translate

Home Page:https://lingva.thedaviddelta.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lingva API return error for texts contains URLs

vitonsky opened this issue · comments

Hi, i'm working on Linguist - browser addon to translate pages, i've implement custom translator for lingva project https://github.com/translate-tools/linguist-translators/blob/c826016314f5f3f68b69d83b9e3182618b991086/translators/LingvaTranslator.js

Users report this issue translate-tools/linguist#354

I've investigated it and as i see, Lingva return error while users trying to translate text of URLs.

Request example

await fetch("https://lingva.ml/api/v1/en/tr/https://github.com/translate-tools/linguist-translators/blob/c826016314f5f3f68b69d83b9e3182618b991086/translators/LingvaTranslator.js", {
    "credentials": "omit",
    "headers": {
        "Accept": "*/*",
        "Accept-Language": "en-US,en;q=0.5",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin"
    },
    "method": "GET",
    "mode": "cors"
}).then(r => r.json());

Actual response

{
  "error": "Not Found"
}

Expected response

Translated text or the same text as in request with no changes

Solution i suggest

Lingva could just return the same text with no changes for cases like this