thedaviddelta / lingva-translate

Alternative front-end for Google Translate
https://lingva.thedaviddelta.com
GNU Affero General Public License v3.0
1.56k stars 144 forks source link

Lingva API return error for texts contains URLs #161

Open vitonsky opened 1 year ago

vitonsky commented 1 year ago

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 https://github.com/translate-tools/linguist/issues/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