Giter VIP home page Giter VIP logo

emacs-immersive-translate's Introduction

immersive-translate: Immersive Bilingual Translation

https://melpa.org/packages/immersive-translate-badge.svg

中文文档

Introductions

Inspired by immersive-translate/immersive-translate, I have implemented similar functionality in Emacs.

Screenshots

elfeed

images/screenshots/elfeed.png

nov

images/screenshots/nov.png

info

images/screenshots/info.png

helpful/help

images/screenshots/help.png

Installation

  1. You need to install curl on your device first. If you want to use the translate-shell backend, you also need to install translate-shell.
  2. M-x package-install RET gptel RET
(require 'immersive-translate)
(add-hook 'elfeed-show-mode-hook #'immersive-translate-setup)
(add-hook 'nov-pre-html-render-hook #'immersive-translate-setup)
;; use Baidu Translation
(setq immersive-translate-backend 'baidu
      immersive-translate-baidu-appid "your-appid")

;; use ChatGPT
;; (setq immersive-translate-backend 'chatgpt
;;       immersive-translate-chatgpt-host "api.openai.com")

;; use translate-shell
;; (setq immersive-translate-backend 'trans)

Usage

  • immersive-translate-buffer

    Translate the current buffer. Note: This may consume a large number of tokens.

  • immersive-translate-paragraph

    Translate the current paragraph.

  • immersive-translate-clear

    Clear all translated text.

  • immersive-translate-auto-mode

    Translate, when enabled, automatically translate the visible portion of the current window.

    Note: Some translation services (e.g. baidu translation) has QPS(Queries Per Second) limits, so it is recommended to use immersive-translate-auto-mode instead of immersive-translate-buffer while using these services.

    • immersive-translate-abort

    Stop all ongoing translation processes in the current buffer.

Customization

  • immersive-translate-backend

    The translation backend used. See API setting for details.

    Currently available translation services:

  • immersive-translate-auto-idle

    After enabling immersive-translate-auto-mode, the Emacs idle time required for the next translation to be executed.

  • immersive-translate-exclude-shr-tag

    The text contained in the tags of this variable will not be translated. This variable applies to all buffers generated by shr.el, such as buffers in elfeed-show-mode, nov-mode, and mu4e-view-mode.

  • immersive-translate-chatgpt-system-prompt

    System prompt used by ChatGPT.

  • immersive-translate-chatgpt-user-prompt

    User prompt used by ChatGPT.

  • immersive-translate-disable-predicates

    When the current paragraph does not need to be translated, return t. These functions in this list do not accept any parameters.

  • immersive-translate-pending-message

    Text displayed before the translation results are returned.

  • immersive-translate-failed-message

    Text displayed when translation fails.

See M-x customize-group RET immersive-translate RET for details.

API setting

The translation service of this plugin requires you to apply for the corresponding API key of the service in order to use it. For more details, please refer to Translation Service API Application

This plugin retrieves the user’s key through the built-in auth-source.el.

  1. ChatGPT

    Assuming your immersive-translate-chatgpt-host is “api.openai.com” and the API key is 123456, add the following text to ~/.authinfo:

    machine api.openai.com login apikey password 123456
        
  2. Baidu Translate

    Assuming your immersive-translate-baidu-appid is “foobar” and the API key is 123456, add the following text to ~/.authinfo:

    machine fanyi-api.baidu.com login foobar password 123456
        
  3. DeepL

    Assuming your API key is 123456, add the following text to ~/.authinfo:

    machine deepl.com login apikey password 123456
        

Add a new translation backend (PRs welcome!)

Add online translation service

If you want to add new translation services, you can check the variables immersive-translate-curl-get-translation-alist and immersive-translate-curl-get-args-alist.

The function in the variable immersive-translate-curl-get-args-alist is used to construct the input parameters required when making a request.

The function in the variable immersive-translate-curl-get-translation-alist is used to parse the translation results returned by curl.

Add local translation services

See immersive-translate-trans.el

emacs-immersive-translate's People

Contributors

elilif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

emacs-immersive-translate's Issues

[Feature Request] Add cache for paragraph translations.

Thank you for your work. Reading foreign language materials in Nov and Elfeed has become a much better experience.

I have a request that I hope you could consider: adding paragraph translation caching. This feature is available in the web version. With this, when a paragraph of text has been translated once, if it's opened again for reading, it can reduce some cost consumption, especially when using ChatGPT as the backend.

Deepl support?

I'm using deepl quite well, but I was wondering if there was any support for that.

Thanks 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.