Skip to content

Commit

Permalink
Add some details, clean a bit.
Browse files Browse the repository at this point in the history
增加一点细节 :)
  • Loading branch information
lorniu committed Oct 11, 2021
1 parent b5df1ec commit 9c0ae87
Show file tree
Hide file tree
Showing 11 changed files with 631 additions and 547 deletions.
5 changes: 3 additions & 2 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
- DeepL,需要自行提供 auth_key

支持多种渲染方式。目前添加的渲染方式有:
- 通过 buffer 显示结果 (默认)
- 将结果拷贝到 Kill-Ring
- 通过 buffer 显示结果
- 通过 posframe 在当前位置弹出结果
- 通过固定一个 posframe 窗口进行渲染 (推荐)
- 通过固定一个 posframe 窗口进行渲染

## 基本使用

Expand Down Expand Up @@ -147,6 +147,7 @@ Whatever you like.
- `x` 交换 `source language``target language` 翻译
- `M-n``M-p`, 切换下一组语言并重新翻译
- `y` 语音播报 (tts)。如果 `gts-tts-try-speak-locally` 为 t,那如果引擎没有提供 tts 服务,将尽量使用本地的 TTS 功能进行播报。比如 windows 上使用 powershell 脚本
- `t` 开关 `gts-buffer-follow-p`。如果设置 `gts-buffer-follow-p` 为 t,翻译完成将会自动跳到 buffer 窗口。通过 `C-x C-x` 可以快速选择翻译结果
- `C` 清空缓存

如果对默认的显示不满意,你可以继承并重写 `gts-buffer-render` 的相关方法。
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Add this to your configuration file:
(setq gts-default-translator
(gts-translator
:picker (gts-prompt-picker)
:engines (list (gts-google-engine) (gts-google-rpc-engine))
:engines (list (gts-bing-engine) (gts-google-engine))
:render (gts-buffer-render)))
```

Expand Down Expand Up @@ -77,8 +77,8 @@ Then use `gts-do-translate` to start translation.
;;(gts-deepl-engine :auth-key [YOUR_AUTH_KEY] :pro nil)
(gts-google-engine :parser (gts-google-summary-parser))
;;(gts-google-engine :parser (gts-google-parser))
;;(gts-google-rpc-engine :parser (gts-google-rpc-summary-parser))
(gts-google-rpc-engine :parser (gts-google-rpc-parser))
;;(gts-google-rpc-engine :parser (gts-google-rpc-summary-parser) :url "https://translate.google.com")
(gts-google-rpc-engine :parser (gts-google-rpc-parser) :url "https://translate.google.com")
)
:render ; render, only one, used to consumer the output result. Install posframe yourself when use gts-posframe-xxx
Expand Down
10 changes: 9 additions & 1 deletion go-translate-v1.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Package-Requires: ((emacs "26.1"))
;; Keywords: convenience
;; SPDX-License-Identifier: MIT
;; Version: 0.1
;; Version: 1.0

;;; Commentary:

Expand Down Expand Up @@ -1259,6 +1259,14 @@ Here we implement it with let-binding style."
(message "%s" (go-translate-result--translation resp)))))
(call-interactively #'go-translate)))

;;; please use new version
(make-obsolete 'go-translate 'gts-do-translate "2.0")
(make-obsolete 'go-translate-popup 'gts-do-translate "2.0")
(make-obsolete 'go-translate-popup-current 'gts-do-translate "2.0")
(make-obsolete 'go-translate-kill-ring-save 'gts-do-translate "2.0")
(make-obsolete 'go-translate-echo-area 'gts-do-translate "2.0")
(make-obsolete 'go-translate-change-local-and-target-language 'gts-do-translate "2.0")


(provide 'go-translate-v1)

Expand Down
95 changes: 47 additions & 48 deletions go-translate.el
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
;;; go-translate.el --- Translation -*- lexical-binding: t -*-
;;; go-translate.el --- Translation framework supports multiple engines such as Google/Bing/DeepL -*- lexical-binding: t -*-

;; Copyright (C) 2021 lorniu <[email protected]>

;; Author: lorniu <[email protected]>
;; URL: https://github.com/lorniu/go-translate
;; Package-Requires: ((emacs "26.1"))
;; Package-Requires: ((emacs "27.1"))
;; Keywords: convenience
;; SPDX-License-Identifier: MIT
;; Version: 0.2
;; Version: 2.0

;;; Commentary:

;; First, Install it via MELPA or download from github.
;; Make sure this is on your `load-path'.
;; To be the most powerful translator on Emacs. Supports multiple translation engines such as Google, Bing, deepL.

;; Then add following lines to your `.emacs':
;; First, Install it via MELPA or download from github. Make sure this is on your `load-path'.

;; (require 'google-translate)
;; (setq gts-translate-list '(("en" "zh")))
;; (setq gts-default-translator
;; (gts-translator
;; :picker (gts-prompt-picker)
;; :engines (list (gts-google-engine) (gts-google-rpc-engine))
;; :render (gts-buffer-render)))
;; Then, add following lines to your `.emacs':

;; Now you can start your translation with `gts-do-translate' command.
;; (require 'go-translate)
;; (setq gts-translate-list '(("en" "zh")))
;; (setq gts-default-translator
;; (gts-translator
;; :picker (gts-prompt-picker)
;; :engines (list (gts-google-engine) (gts-google-rpc-engine))
;; :render (gts-buffer-render)))

;; And start your translate with command `gts-do-translate'.

;;; Code:

Expand All @@ -45,40 +46,38 @@
;;; Commands

(defvar gts-default-translator
(gts-translator

:picker
;;(gts-noprompt-picker)
;;(gts-noprompt-picker :texter (gts-whole-buffer-texter))

(gts-prompt-picker)
;;(gts-prompt-picker :single t)
;;(gts-prompt-picker :texter (gts-current-or-selection-texter) :single t)

:engines
(list
(gts-bing-engine)
;;(gts-google-engine)
;;(gts-google-rpc-engine)
;;(gts-deepl-engine :auth-key "2e20bade-88e9-02f3-169f-ab3c445d7984:fx" :pro nil)

;;(gts-google-engine :parser (gts-google-summary-parser))
;;(gts-google-engine :parser (gts-google-parser))
;;(gts-google-rpc-engine :parser (gts-google-rpc-summary-parser))
)

:render
(gts-buffer-render)

;;(gts-posframe-pop-render)
;;(gts-posframe-pop-render :backcolor "#333333" :forecolor "#ffffff")

;;(gts-posframe-pin-render)
;;(gts-posframe-pin-render :position (cons 1200 20))
;;(gts-posframe-pin-render :width 80 :height 25 :position (cons 1000 20) :forecolor "#ffffff" :backcolor "#111111")

;;(gts-kill-ring-render)
))
(gts-translator :picker
(gts-prompt-picker)
;;(gts-noprompt-picker)
;;(gts-noprompt-picker :texter (gts-whole-buffer-texter))

:engines
(list
(gts-bing-engine)
(gts-google-engine :parser (gts-google-summary-parser))
(gts-google-rpc-engine)

;;(gts-google-engine)
;;(gts-google-rpc-engine)
;;(gts-deepl-engine :auth-key "2e20bade-88e9-02f3-169f-ab3c445d7984:fx" :pro nil)

;;(gts-google-engine :parser (gts-google-summary-parser))
;;(gts-google-engine :parser (gts-google-parser))
;;(gts-google-rpc-engine :parser (gts-google-rpc-summary-parser))
)

:render
(gts-buffer-render)

;;(gts-posframe-pop-render)
;;(gts-posframe-pop-render :backcolor "#333333" :forecolor "#ffffff")

;;(gts-posframe-pin-render)
;;(gts-posframe-pin-render :position (cons 1200 20))
;;(gts-posframe-pin-render :width 80 :height 25 :position (cons 1000 20) :forecolor "#ffffff" :backcolor "#111111")

;;(gts-kill-ring-render)
))

;;;###autoload
(defun gts-do-translate ()
Expand Down
Loading

0 comments on commit 9c0ae87

Please sign in to comment.