Translate fix
Fix problem when Googole Transtale replace "" on «» during translation, what broke the syntax
This commit is contained in:
parent
5bb20519b7
commit
bf682be17a
|
@ -86,7 +86,11 @@ router.post('/google', jsonParser, async (request, response) => {
|
||||||
try {
|
try {
|
||||||
const result = normaliseResponse(JSON.parse(data));
|
const result = normaliseResponse(JSON.parse(data));
|
||||||
console.log('Translated text: ' + result.text);
|
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) {
|
} catch (error) {
|
||||||
console.log('Translation error', error);
|
console.log('Translation error', error);
|
||||||
return response.sendStatus(500);
|
return response.sendStatus(500);
|
||||||
|
|
Loading…
Reference in New Issue