Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/akirak/emacs-dumb-japanese

(Experimental) An opinionated Japanese input method that never learns your language
https://github.com/akirak/emacs-dumb-japanese

emacs input-method japanese

Last synced: 7 days ago
JSON representation

(Experimental) An opinionated Japanese input method that never learns your language

Awesome Lists containing this project

README

        

* Dumb Japanese Input Method for Emacs (riben.el)
This is a Japanese input method for Emacs that depends on a service of Google.
It does not require a native library/executable (unlike mozc.el), nor an offline dictionary (unlike ddskk).
It is written in pure Emacs Lisp and depends on the internet.

About the name: Rìběn means Japan in Mandarin Chinese.
Since this input method requires connection to Google, it is unlikely you can use it in the mainland China.
You can use it in Japan and most of the other countries.
** Rationale
The goal of this project is to provide a Japanese input method that requires minimal dependencies but is still usable.

It is primarily intended for daily communication at work.
Its features are limited, and you may find it difficult to produce exact transliteration you want to express.
It is not a goal of this project to support authors of Japanese literature.
** Installation
This repository currently contains two packages.

The first one is =riben= package which consists of all elisp files but =avy-riben.el=.
You can use the folowing recipe:

#+begin_src emacs-lisp
(riben :fetcher github :repo "akirak/emacs-dumb-japanese"
:files (:defaults (:exclude "avy-riben.el")))
#+end_src

The other is =avy-riben=, which lets you jump to a point on a visible text using furigana.
It consists of a single file =avy-riben.el=, and it depends on =riben= and [[https://github.com/abo-abo/avy][avy]]:

#+begin_src emacs-lisp
(avy-riben :fetcher github :repo "akirak/emacs-dumb-japanese"
:files ("avy-riben.el"))
#+end_src

=riben= provides some features that depend on Google Translate.
To use those features, you have to install [[https://github.com/lorniu/go-translate][go-translate]] as well.
** Configuration
Below is an example:

#+begin_src emacs-lisp
;; These keybindings are optional
(define-key riben-mode-map (kbd "C-j") #'riben-dispatch)
(define-key riben-mode-map (kbd "C-S-j") #'riben-inc-counter)
(define-key riben-mode-map (kbd "q") #'riben-mode-disable)
(define-key riben-mode-map (kbd "@") #'riben-switch-to-english-mode)

;; Workaround for commands in `org-mode-map' and other maps.
(with-eval-after-load 'riben
(dolist (key (mapcar #'car riben-decode-punctuation-alist))
(define-key riben-mode-map (vector key) #'riben-self-insert-command)))
#+end_src
** Usage
Switch to =japanese-riben= input method, or turn on =riben-mode=.

It transliterates the input when you press a comma, period, or space.

Alternatively, you can transliterate any Hiragana text in a buffer by selecting the text and running =riben-dispatch= command.
*** Typing katakana literally
If you neeed to type katakana, you can use =riben-katakana-mode=.
You can also use =japanese-katakana= input method which is built into Emacs, but it is not based on the same romaji scheme as riben.
*** Producing katakana from English
You can also produce Katakana corresponding to an English word.
For example, you can produce "コンポーネント" by typing "component".

To use this feature, turn on =riben-english-mode=, or run =riben-switch-to-english-mode= when you are inside =riben-mode=.
Type an English word, and it is translated into katakana when you press space.
=riben-switch-to-english-mode= makes Emacs switch back to =riben-mode= after translation, so it is convenient if you want to include foreign words in Japanese.

If the mode doesn't provide translation for a word, you can add it manually using =riben-english-register-katakana=.
It stores translations in a SQLite database.
*** Translating an English word into Japanese
If you press =.= instead of space in =riben-english-mode=, you can choose which Japanese translation to insert into the buffer.
This can be convenient if you don't remember the Japanese translation for an English word.
*** Jumping to Japanese
=avy-riben= command jumps the point to text using [[https://github.com/abo-abo/avy][avy]] like [[https://github.com/momomo5717/avy-migemo][avy-migemo]] does, but without dictionary files.
** Caveats
As mentioned above, this input method requires connection to a Google server.

It should also be noted that =riben-mode= remaps =self-insert-command=.
It does not work if you are using another minor mode that remaps =self-insert-command= for letter keys, like [[https://github.com/abo-abo/lispy][lispy]] does.
I personally don't take this issue seriously, because I have never experienced a situation where I need to write Japanese in =emacs-lisp-mode=.
** Alternatives
As far I know, there are a couple of Japanese input methods for Emacs that are actively developed:

- [[https://github.com/skk-dev/ddskk/][DDSKK]], which requires dictionaries
- [[https://github.com/google/mozc/][Mozc]] (a.k.a. Google Japanese Input), which requires a binary

Another option is [[https://github.com/gkovacs/rime-japanese][rime-japanese]], which is a schema for the [[https://github.com/rime][RIME]] input engine, which is primarily developed for Chinese speaking people.
[[https://github.com/tumashu/pyim][PYIM]] supports rime, so it would be possible to use rime-japanese via pyim.
Unfortunately, these options are relatively hard to set up, and it does not officially support Emacs 29 yet.
** Inspirations
This project was originally inspired by the following projects:

- [[https://github.com/igjit/ac-mozc][ac-mozc]]
- [[http://blog.sushi.money/entry/20110421/1303274561][Google IME SKK サーバー 作った]]

There are some other features inspired by the following projects:

- [[https://github.com/manateelazycat/insert-translated-name][insert-translated-name]]
- [[https://github.com/skk-dev/ddskk][ddskk]]