2022-03-24 06:17:33 +00:00
|
|
|
#+TITLE: Translate Layer
|
|
|
|
|
|
|
|
#+TAGS: layer|tool
|
|
|
|
|
|
|
|
[[file:img/screen-record.gif]]
|
|
|
|
|
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#features][Features:]]
|
|
|
|
- [[#install][Install]]
|
|
|
|
- [[#usage][Usage]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#language-pair][Language Pair]]
|
|
|
|
- [[#highlighting][Highlighting]]
|
|
|
|
- [[#read-only][Read-only]]
|
|
|
|
- [[#face][Face]]
|
|
|
|
- [[#key-bindings][Key bindings]]
|
2022-03-28 04:32:10 +00:00
|
|
|
- [[#variables][Variables]]
|
2022-03-24 06:17:33 +00:00
|
|
|
|
|
|
|
* Description
|
|
|
|
This layer is designed for Paragraph-oriented minor mode for
|
|
|
|
side-by-side document translation workflow.
|
|
|
|
|
|
|
|
** Features:
|
|
|
|
- Paragraph-oriented side-by-side document translation workflow
|
|
|
|
- Integrate word/paragraph online translation
|
|
|
|
|
|
|
|
* Install
|
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
|
|
add =translate= to the existing =dotspacemacs-configuration-layers= list in this file.
|
|
|
|
|
|
|
|
* Usage
|
|
|
|
It's quite simple to use this layer. Open the translation file you are currently working
|
|
|
|
on, and call command =translate-open-reference-file= or =translate-select-reference-buffer=
|
|
|
|
to set the reference buffer or open an existed reference file. Now you can just keep your
|
|
|
|
cursor in your translation buffer. The cursor in the reference buffer will be kept in
|
|
|
|
sync with the cursor in the translation buffer.
|
|
|
|
|
|
|
|
* Configuration
|
|
|
|
All layer configurations can be done by setting layer variables in your dotfile.
|
|
|
|
No custom user config lines are necessary. For more details please see the homepage
|
|
|
|
of package [[https://github.com/rayw000/translate-mode][translate-mode]] and [[https://github.com/lorniu/go-translate/][go-translate]].
|
|
|
|
|
|
|
|
** Language Pair
|
|
|
|
You need to set language pairs to make online translation work.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(translate :variables gts-translate-list '(("en" "zh") ("en" "fr")))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Highlighting
|
|
|
|
Set =translate-enable-highlight= to =nil= to disable highlighting.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(translate :variables translate-enable-highlight nil)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Read-only
|
|
|
|
You can set =translate-reference-buffer-read-only= to =t= to make the reference buffer read-only.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(translate :variables translate-reference-buffer-read-only t)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Face
|
|
|
|
The face of highlight paragraph can be customized by =translate-paragraph-highlight-face=.
|
|
|
|
Put this following line into =custom-set-faces= in your =~/.spacemacs~ file to set the background
|
|
|
|
color to red, for example.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2022-05-13 16:52:02 +00:00
|
|
|
'(translate-paragraph-highlight ((t (:extend t :background "red"))))
|
2022-03-24 06:17:33 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Key bindings
|
|
|
|
|
|
|
|
| Key binding | Description |
|
|
|
|
|---------------+------------------------------------------------------------------------------|
|
|
|
|
| ~SPC a t T t~ | Toggle =translate-mode= |
|
|
|
|
| ~SPC a t T p~ | Open a translation list buffer for current paragraph in the reference buffer |
|
|
|
|
| ~SPC a t T w~ | Popup translation list for word at point, also can be used on regions |
|
|
|
|
| ~SPC a t T f~ | Prompt to open the reference file |
|
|
|
|
| ~SPC a t T b~ | Prompt to select a buffer and set it as the reference buffer |
|
|
|
|
| ~SPC a t T h~ | Toggle paragraph highlighting |
|
2022-03-28 04:32:10 +00:00
|
|
|
|
|
|
|
* Variables
|
|
|
|
These variables can be used to customize =translate= layer.
|
|
|
|
|
|
|
|
| Variable | Default Value | Description |
|
|
|
|
|------------------------------+---------------+---------------------------------------------------------------------------|
|
|
|
|
| =translate/paragraph-render= | ='posframe= | Paragraph translation render. Valid values are ='posframe= and ='buffer=. |
|
|
|
|
| =translate/word-render= | ='posframe= | Word translation render. Valid values are ='posframe= and ='buffer=. |
|