aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.ts
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-08-17 22:54:41 +0100
committerLibravatar GitHub <noreply@github.com>2022-08-17 22:54:41 +0100
commitfb0cc81d1db0d88c90bb112a0caec66095fcc0f0 (patch)
treeaaa5d0f92f55ccf3984af2cbf2ebbcb1da5fd7c6 /src/index.ts
parent6.0.1-nightly.16 [skip ci] (diff)
downloadferdium-app-fb0cc81d1db0d88c90bb112a0caec66095fcc0f0.tar.gz
ferdium-app-fb0cc81d1db0d88c90bb112a0caec66095fcc0f0.tar.zst
ferdium-app-fb0cc81d1db0d88c90bb112a0caec66095fcc0f0.zip
Feature: Add Ferdium Translator (#548)
Add feature to translate text natively using https://github.com/shikar/NODE_GOOGLE_TRANSLATE package and a LibreTranslate self-hosted option (already running on our server on https://translator.ferdium.org).
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts
index 05e222a25..7c80ca955 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -45,6 +45,7 @@ import './electron/exception';
45import { asarPath } from './helpers/asar-helpers'; 45import { asarPath } from './helpers/asar-helpers';
46import { openExternalUrl } from './helpers/url-helpers'; 46import { openExternalUrl } from './helpers/url-helpers';
47import userAgent from './helpers/userAgent-helpers'; 47import userAgent from './helpers/userAgent-helpers';
48import { translateTo } from './helpers/translation-helpers';
48 49
49const debug = require('./preload-safe-debug')('Ferdium:App'); 50const debug = require('./preload-safe-debug')('Ferdium:App');
50 51
@@ -500,6 +501,18 @@ app.on('login', (event, _webContents, _request, authInfo, callback) => {
500 } 501 }
501}); 502});
502 503
504ipcMain.handle(
505 'translate',
506 async (_e, { text, translateToLanguage, translatorEngine }) => {
507 const response = await translateTo(
508 text,
509 translateToLanguage,
510 translatorEngine,
511 );
512 return response;
513 },
514);
515
503// TODO: evaluate if we need to store the authCallback for every service 516// TODO: evaluate if we need to store the authCallback for every service
504ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => { 517ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => {
505 debug('Received basic auth credentials', user, '********'); 518 debug('Received basic auth credentials', user, '********');