Elilif / emacs-immersive-translate

Immersive-translate provides bilingual simultaneous display and translation of any text in Emacs.
GNU General Public License v3.0
70 stars 9 forks source link

[Feature Request] Hope this package can separate front-end and translating backends #1

Closed stardiviner closed 1 year ago

stardiviner commented 1 year ago

As title described, so that other contributors can add other translating backends.

Elilif commented 1 year ago

@stardiviner This is what I will do in the next stage. Currently, I have just completed the preliminary formatting work for the front-end.

stardiviner commented 1 year ago

Thanks for quick respond. Great, wait for in new release.

Elilif commented 1 year ago

@stardiviner I have implemented the relevant functionality preliminarily (see 添加新的翻译服务), but I am unsure if this is appropriate. If you have any ideas, please let me know.

stardiviner commented 1 year ago

Thanks for quick added feature! I checked out the new release commit. I know for current translating services status, almost 97% services are online URL API. But I think this Emacs extension should also support offline local translating software which has command-line or other schema support. So I think the core API function immersive-translate-curl-do should be like immersive-translate-translate (name it as you like). The immersive-translate-curl-get-translation-alist also need to be modified to suite for a translating backend interface function as a blackbox instead of unified cURL requesting, cURL requesting functions can be in a common library file immersive-translate-curl-common.el. For example:

(defcustom immersive-translate-backend-functions-alist
  '((chatgpt . immersive-translate-chatgpt-get-translation)
     (baidu . immersive-translate-chatgpt-get-translation)
     (goldendict . immersive-translate-goldendict-get-translation) ; Here give goldendict as an example
)
.........
(defun immersive-translate-goldendict-get-translation (text)
  "Translate input TEXT then return an Elisp data structure like alist etc?"
  .....)

Those are my little opinions. WDYT?

Elilif commented 1 year ago

@stardiviner

But I think this Emacs extension should also support offline local translating software which has command-line or other schema support.

This package is intended to translate long texts, which means paragraphs are considered as the smallest unit. I don't know whether there is local offline translation software that can do this well. If there is, could you submit a PR? Because I am not very familiar with the relevant knowledge.

stardiviner commented 1 year ago

macOS Bob.app support translating long text through AppleScript command-line invocation. For example: https://repo.or.cz/external-dict.el.git/blobdiff/e178548b9d88d86881aa870ae743ee4b82089533..68ab3e5f78239774d1710874e8a68e3f8498cee3:/external-dict.el

Elilif commented 1 year ago

@stardiviner Thank you for your suggestion! I tried to make some improvements based on your advice (see 1090e1c74c3c2d296c1f74807ca2ec37cdf27fed and sorry for my chaotic commits.). Since I only have Linux devices on hand, I tested it using translate-shell , and the results were good.

stardiviner commented 1 year ago

Thanks for quick response. Looks great for me. Close now.