Translate fix

Fix problem when Googole Transtale replace "" on «» during translation, what broke the syntax
This commit is contained in:
Himickoff 2024-07-13 18:42:30 +07:00
parent 5bb20519b7
commit bf682be17a
1 changed files with 5 additions and 1 deletions

View File

@ -86,7 +86,11 @@ router.post('/google', jsonParser, async (request, response) => {
try {
const result = normaliseResponse(JSON.parse(data));
console.log('Translated text: ' + result.text);
return response.send(result.text);
// Заменяем кавычки «» на ""
const fixedText = result.text.replace(/«/g, '"').replace(/»/g, '"');
return response.send(fixedText);
} catch (error) {
console.log('Translation error', error);
return response.sendStatus(500);