johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.1k stars 282 forks source link

Integrate with a custom translator/dictionary #791

Open gyunaev opened 2 years ago

gyunaev commented 2 years ago

The built-in translator supports Google Translate, which is great option for some languages, but not that great for many others.

Instead of adding support for all the translators and dictionaries around there, would it be possible to allow the user to invoke a specified app upon "translate" action, and show the output of the app in the "translation results" window? This would allow contributors to write custom support for various translators, dictionaries and so on, including DeepL, GoldenDict, libretranslate.com and so on.

The invocation interface should probably as simple as the following:

johnfactotum commented 2 years ago

Technically speaking, this is a special case of #359.

bxb2world commented 1 month ago

The built-in translator supports Google Translate, which is great option for some languages, but not that great for many others.

Instead of adding support for all the translators and dictionaries around there, would it be possible to allow the user to invoke a specified app upon "translate" action, and show the output of the app in the "translation results" window? This would allow contributors to write custom support for various translators, dictionaries and so on, including DeepL, GoldenDict, libretranslate.com and so on.

The invocation interface should probably as simple as the following:

  • When Translate clicked, Foliate launches an app specified in settings;
  • The selected text is written to the app's stdin, which is closed afterward;
  • The app is supposed to write the translation/dictionary lookup/whatever in HTML format into stdout (including errors);
  • Foliate reads apps output and shows the result in the Translation window.

Yes, it's true, for European Portuguese, for example, Google Translate is not a good option. In this case, DeepL works very well. Being able to use it would be great.