Closed Cohee1207 closed 9 months ago
Environment Package version: 4.3.0 Node version: v21.6.1 OS: Windows 11 22H2
Description Translating a text that contains a newline character fails with 400 Bad Request from Google.
Steps to reproduce
import { translate } from 'google-translate-api-browser'; async function translateText(text, lang) { try { const result = await translate(text, { to: lang }); console.log(result.text); } catch (error) { console.log('Translation error: ' + error); } } await translateText(`Hello\nWorld`, 'es'); export { };
Expected result Full translated text displayed in the console.
Actual result Translation fails with an error. Here's an actual response body returned by Google
)]}' 102 [["er",null,null,null,null,400,null,null,null,3],["di",7],["af.httprm",7,"-8758994509752400712",34]] 25 [["e",4,null,null,138]]
This should be fixed in version 4.3.1
4.3.1
Environment Package version: 4.3.0 Node version: v21.6.1 OS: Windows 11 22H2
Description Translating a text that contains a newline character fails with 400 Bad Request from Google.
Steps to reproduce
Expected result Full translated text displayed in the console.
Actual result Translation fails with an error. Here's an actual response body returned by Google