diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-08-17 22:54:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 22:54:41 +0100 |
commit | fb0cc81d1db0d88c90bb112a0caec66095fcc0f0 (patch) | |
tree | aaa5d0f92f55ccf3984af2cbf2ebbcb1da5fd7c6 /src/index.ts | |
parent | 6.0.1-nightly.16 [skip ci] (diff) | |
download | ferdium-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.ts | 13 |
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'; | |||
45 | import { asarPath } from './helpers/asar-helpers'; | 45 | import { asarPath } from './helpers/asar-helpers'; |
46 | import { openExternalUrl } from './helpers/url-helpers'; | 46 | import { openExternalUrl } from './helpers/url-helpers'; |
47 | import userAgent from './helpers/userAgent-helpers'; | 47 | import userAgent from './helpers/userAgent-helpers'; |
48 | import { translateTo } from './helpers/translation-helpers'; | ||
48 | 49 | ||
49 | const debug = require('./preload-safe-debug')('Ferdium:App'); | 50 | const 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 | ||
504 | ipcMain.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 |
504 | ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => { | 517 | ipcMain.on('feature-basic-auth-credentials', (_e, { user, password }) => { |
505 | debug('Received basic auth credentials', user, '********'); | 518 | debug('Received basic auth credentials', user, '********'); |