aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/translation-helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/translation-helpers.ts')
-rw-r--r--src/helpers/translation-helpers.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/helpers/translation-helpers.ts b/src/helpers/translation-helpers.ts
index 215b2a49c..0edd95412 100644
--- a/src/helpers/translation-helpers.ts
+++ b/src/helpers/translation-helpers.ts
@@ -1,5 +1,5 @@
1import fetch from 'node-fetch'; 1import fetch from 'node-fetch';
2import translateGoogle from 'translate-google'; 2import translateGoogle from 'google-translate-api-x';
3import { LIVE_API_FERDIUM_LIBRETRANSLATE } from '../config'; 3import { LIVE_API_FERDIUM_LIBRETRANSLATE } from '../config';
4 4
5export async function translateTo( 5export async function translateTo(
@@ -12,16 +12,17 @@ export async function translateTo(
12 'FERDIUM ERROR: An error occured. Please select less text to translate or try again later.'; 12 'FERDIUM ERROR: An error occured. Please select less text to translate or try again later.';
13 13
14 if (translatorEngine === 'Google') { 14 if (translatorEngine === 'Google') {
15 try { 15 const translationResult = await translateGoogle(text, {
16 const res = await translateGoogle(text, { 16 to: translateToLanguage,
17 to: translateToLanguage, 17 autoCorrect: true,
18 }); 18 })
19 .then(res => ({ text: res.text, error: false }))
20 .catch(() => ({ text: errorText, error: true }));
19 21
20 return { text: res, error: false }; 22 return translationResult;
21 } catch { 23 }
22 return { text: errorText, error: true }; 24
23 } 25 if (translatorEngine === 'LibreTranslate') {
24 } else if (translatorEngine === 'LibreTranslate') {
25 try { 26 try {
26 const res = await fetch(LIVE_API_FERDIUM_LIBRETRANSLATE, { 27 const res = await fetch(LIVE_API_FERDIUM_LIBRETRANSLATE, {
27 method: 'POST', 28 method: 'POST',